From 29f25edd2fabd8a8218309cee7229587cefcc914 Mon Sep 17 00:00:00 2001 From: JYEtech Date: Sun, 7 May 2017 20:48:04 -0400 Subject: [PATCH] Add files via upload --- 113-15011.c | 180 +++++ Board.c | 1512 +++++++++++++++++++++++++++++++++++ Board.h | 996 +++++++++++++++++++++++ Command.c | 1540 ++++++++++++++++++++++++++++++++++++ Command.h | 205 +++++ Common.c | 67 ++ Common.h | 71 ++ Eeprom.c | 644 +++++++++++++++ Eeprom.h | 113 +++ Makefile | 617 +++++++++++++++ STM32F10x_64k_20k_flash.ld | 251 ++++++ Screen.c | 696 ++++++++++++++++ Screen.h | 141 ++++ libdso150.a | Bin 0 -> 43452 bytes libdso150.h | 244 ++++++ readme.txt | 76 ++ startup_stm32f10x_md.S | 357 +++++++++ stm32f10x_conf.h | 77 ++ stm32f10x_it.c | 184 +++++ stm32f10x_it.h | 49 ++ 20 files changed, 8020 insertions(+) create mode 100644 113-15011.c create mode 100644 Board.c create mode 100644 Board.h create mode 100644 Command.c create mode 100644 Command.h create mode 100644 Common.c create mode 100644 Common.h create mode 100644 Eeprom.c create mode 100644 Eeprom.h create mode 100644 Makefile create mode 100644 STM32F10x_64k_20k_flash.ld create mode 100644 Screen.c create mode 100644 Screen.h create mode 100644 libdso150.a create mode 100644 libdso150.h create mode 100644 readme.txt create mode 100644 startup_stm32f10x_md.S create mode 100644 stm32f10x_conf.h create mode 100644 stm32f10x_it.c create mode 100644 stm32f10x_it.h diff --git a/113-15011.c b/113-15011.c new file mode 100644 index 0000000..98a2150 --- /dev/null +++ b/113-15011.c @@ -0,0 +1,180 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: 113-15011.c +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +// Descriptions: Main firmware for DSO Shell +// PCB: 109-15000-00D or later +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// ATTENTION: +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// + +#include "stm32f10x.h" +#include "stm32f10x_conf.h" + +#include "Common.h" +#include "Board.h" +#include "Screen.h" +#include "Command.h" +#include "Eeprom.h" + +#include "libdso150.h" + +const U8 Model[12] = {"\n\rDSO Shell"}; +const U8 MFG[16] = {"\n\rJYE Tech Ltd."}; +const U8 Website[20] = {"\n\rWWW.JYETECH.COM\n\r"}; +const U8 FWver[20] = {"FW: 113-15011-060"}; + +int main (void) +{ + U16 tmp1, tmp2; + U32 tmp; + + Clock_Init(); + + Port_Init(); + + /* Unlock the Flash Program Erase controller */ + FLASH_Unlock(); + + /* EEPROM Init */ + EE_Init(); + + USART1_Init(); + ADC2_Init(); + TFT_Init_Ili9341(); + + uputs((U8 *)Model, USART1); + uputs((U8 *)MFG, USART1); + uputs((U8 *)Website, USART1); + uputs((U8 *)FWver, USART1); + + tmp = TFT_ReadID_Ili9341(); + if((tmp & 0x0000FFFF) == 0x9341) { + // Found 9341 controller + TFT_Controller = 0x9341; + } + else { + TFT_Init_Ili9325(); + TFT_Controller = 0x9325; + } + + ClrScreen(); + SysTick_Init(); + TIM3_Init(); // Test signal + + NVIC_Configuration(); + + tmp1 = clBlack; + FillRect(ScreenX0, ScreenY0, ScreenXsize, ScreenYsize, tmp1); + PutcGenic(24, 50, 0, clAqua, tmp1, &DSO_Shell); + PutcGenic(120, 52, 0, clAqua, tmp1, &ByJyetech); + PutcGenic(24, 75, 0, clAqua, tmp1, &Web); + PutsGenic(24, 100, (U8 *)FWver, clWhite, tmp1, &ASC8X16); + PutsGenic(24, 120, (U8 *)LibVersion, clWhite, tmp1, &ASC8X16); + + AppInit(); + + BitClr(Keypad.Flags, (1 << KF_KeyHit)); + tmp1 = 100; + while(tmp1) { + KeyScan(); + Delay(65500); + tmp1--; + } + + if(BitTest(Keypad.Flags, (1 << KF_KeyHit))) { + // Pause + BitClr(Keypad.Flags, (1 << KF_KeyHit)); + while(!BitTest(Keypad.Flags, (1 << KF_KeyHit))) { + KeyScan(); + } + } + + tmp1 = clWhite; + FillRect(ScreenX0, ScreenY0, ScreenXsize, ScreenYsize, tmp1); + + PutcGenic(20, 71, 0, clRed, tmp1, &DSOm); + PutcGenic(140, 70, 0, clBlue, tmp1, &Shell); + PutcGenic(24, 115, 0, clBlack, tmp1, &Web); + PutcGenic(20, 180, 0, clBlue, tmp1, &JYELogo); + PutcGenic(90, 178, 0, clBlue, tmp1, &Jinyuedianzi); + PutcGenic(90, 200, 0, clBlue, tmp1, &Jyetech); + + // LED blinks twice + LedBlink(); + + UpdateDisp(Disp_Panel | Disp_Param); + GTimer = 1000; + GTimeout = 0; + + // The main loop + while(1) { + DsoDisplay(); + + if(BitTest(AddOns, (1 << AO_MeasurementOn))) { + OnScreenDisplay(); + } + + if(BitTest(AddOns, (1 << AO_TestSigAmpDisp))) { + TestSigAmpDisplay(); + } + + if(GTimeout) { + GTimeout = 0; + StartCapture(); + } + + if(BitTest(Keypad.Flags, (1 << KF_DoKeyScan))) { + BitClr(Keypad.Flags, (1 << KF_DoKeyScan)); + // Do key scan + KeyScan(); + } + + if(Keypad.KeyCode) { + // Process key code + KeyProc(); + Keypad.KeyCode = 0; + } + + tmp1 = GetDsoStatus(); + if(GTimer == 0) { + if(BitTest(tmp1, DSO_CaptureDone)) { + Measurements(); + UpdateDisp(Disp_Trace); + tmp2 = GetTimebase(); + if(tmp2 <= TB_1ms) { + // Start next capture + StartCapture(); + } + else { + // Lower capture rate + GTimer = 40; + } + } + } + + if(BitTest(tmp1, DSO_Rolling)) { + Measurements(); + Rolling(); + } + + } + +} + diff --git a/Board.c b/Board.c new file mode 100644 index 0000000..e467fbf --- /dev/null +++ b/Board.c @@ -0,0 +1,1512 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Board.c +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech Ltd. +// Web: www.jyetech.com +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#include "stm32f10x.h" + +#include "Common.h" +#include "Board.h" +#include "libdso150.h" + +// =========================================================== +// File Scope Variables +// =========================================================== +// +const U8 VSenCtrlTab[13] = { + // {X, X, X, SENSEL[3:0], X } + 0b00000110, // 20V + 0b00001010, // 10V + 0b00000000, // 5V + 0b00001110, // 2V + 0b00001100, // 1V + 0b00001000, // 0.5V + 0b00010110, // 0.2V + 0b00011010, // 0.1V + 0b00010000, // 50mV + 0b00011110, // 20mV + 0b00011100, // 10mV + 0b00011000, // 5mV + 0b00000010 // GND + }; + + +U16 GTimer; +U8 GTimeout; + +U16 TimerKeyScan; + +U16 TFT_Controller; + +// =========================================================== +// Function Definitions +// =========================================================== + +//----------------------------------------------------------------------------- +// Clock_Init +//----------------------------------------------------------------------------- +// +void Clock_Init(void) +{ + RCC->CR = (1 << HSION) /*!< Internal High Speed clock enable */ + |(0 << HSIRDY) /*!< Internal High Speed clock ready flag */ + |(0x10 << HSITRIM) /*!< Internal High Speed clock trimming */ + |(0 << HSICAL) /*!< Internal High Speed clock Calibration */ + |(1 << HSEON) /*!< External High Speed clock enable */ + |(0 << HSERDY) /*!< External High Speed clock ready flag */ + |(0 << HSEBYP) /*!< External High Speed clock Bypass */ + |(0 << CSSON) /*!< Clock Security System enable */ + |(0 << PLLON) /*!< PLL enable */ + |(0 << PLLRDY); /*!< PLL clock ready flag */ + +// MCO[2:0] : Microcontroller clock output +// 0xx: No clock +// 100: System clock (SYSCLK) selected +// 101: HSI clock selected +// 110: HSE clock selected +// 111: PLL clock divided by 2 selected +// +// USBPRE: USB prescaler +// Set and cleared by software to generate 48 MHz USB clock. This bit must be valid before +// enabling the USB clock in the RCC_APB1ENR register. This bit can’t be reset if the USB +// clock is enabled. +// 0: PLL clock is divided by 1.5 +// 1: PLL clock is not divided +// +// PLLMUL[3:0] : PLL multiplication factor +// These bits are written by software to define the PLL multiplication factor. These bits can be +// written only when PLL is disabled. +// 0000: PLL input clock x 2 +// 0001: PLL input clock x 3 +// 0010: PLL input clock x 4 +// 0011: PLL input clock x 5 +// 0100: PLL input clock x 6 +// 0101: PLL input clock x 7 +// 0110: PLL input clock x 8 +// 0111: PLL input clock x 9 +// 1000: PLL input clock x 10 +// 1001: PLL input clock x 11 +// 1010: PLL input clock x 12 +// 1011: PLL input clock x 13 +// 1100: PLL input clock x 14 +// 1101: PLL input clock x 15 +// 1110: PLL input clock x 16 +// 1111: PLL input clock x 16 +// +// PLLXTPRE: HSE divider for PLL entry +// Set and cleared by software to divide HSE before PLL entry. This bit can be written only +// when PLL is disabled. +// 0: HSE clock not divided +// 1: HSE clock divided by 2 +// +// PLLSRC: PLL entry clock source +// Set and cleared by software to select PLL clock source. This bit can be written only when +// PLL is disabled. +// 0: HSI oscillator clock / 2 selected as PLL input clock +// 1: HSE oscillator clock selected as PLL input clock +// +// ADCPRE[1:0] : ADC prescaler +// Set and cleared by software to select the frequency of the clock to the ADCs. +// 00: PLCK2 divided by 2 +// 01: PLCK2 divided by 4 +// 10: PLCK2 divided by 6 +// 11: PLCK2 divided by 8 +// +// PPRE2[2:0] : APB high-speed prescaler (APB2) +// Set and cleared by software to control the division factor of the APB high-speed clock +// (PCLK2). +// 0xx: HCLK not divided +// 100: HCLK divided by 2 +// 101: HCLK divided by 4 +// 110: HCLK divided by 8 +// 111: HCLK divided by 16 + +// PPRE1[2:0] : APB low-speed prescaler (APB1) +// Set and cleared by software to control the division factor of the APB low-speed clock +// (PCLK1). +// Warning: the software has to set correctly these bits to not exceed 36 MHz on this domain. +// 0xx: HCLK not divided +// 100: HCLK divided by 2 +// 101: HCLK divided by 4 +// 110: HCLK divided by 8 +// 111: HCLK divided by 16 + +// HPRE[3:0] : AHB prescaler +// Set and cleared by software to control the division factor of the AHB clock. +// 0xxx: SYSCLK not divided +// 1000: SYSCLK divided by 2 +// 1001: SYSCLK divided by 4 +// 1010: SYSCLK divided by 8 +// 1011: SYSCLK divided by 16 +// 1100: SYSCLK divided by 64 +// 1101: SYSCLK divided by 128 +// 1110: SYSCLK divided by 256 +// 1111: SYSCLK divided by 512 +// +// SWS[1:0] : System clock switch status +// Set and cleared by hardware to indicate which clock source is used as system clock. +// 00: HSI oscillator used as system clock +// 01: HSE oscillator used as system clock +// 10: PLL used as system clock +// 11: not applicable + +// SW[1:0] : System clock switch +// Set and cleared by software to select SYSCLK source. +// Set by hardware to force HSI selection when leaving Stop and Standby mode or in case of +// failure of the HSE oscillator used directly or indirectly as system clock (if the Clock Security +// System is enabled). +// 00: HSI selected as system clock +// 01: HSE selected as system clock +// 10: PLL selected as system clock +// 11: not allowed +// + RCC->CFGR = (0 << SW) /*!< SW[1:0] bits (System clock Switch) */ + |(0 << SWS) /*!< SWS[1:0] bits (System Clock Switch Status) */ + |(0 << HPRE) /*!< HPRE[3:0] bits (AHB prescaler) [HCLK] */ + |(0b100 << PPRE1) /*!< PRE1[2:0] bits (APB1 prescaler) [PCLK1] */ + |(0 << PPRE2) /*!< PRE2[2:0] bits (APB2 prescaler) [PCLK2] */ + |(2 << ADCPRE) /*!< ADCPRE[1:0] bits (ADC prescaler) */ + |(1 << PLLSRC) /*!< PLL entry clock source */ + |(0 << PLLXTPRE) /*!< HSE divider for PLL entry */ + |(7 << PLLMULL) /*!< PLLMUL[3:0] bits (PLL multiplication factor) */ + |(0 << USBPRE) /*!< USB Device prescaler */ + |(0 << MCO); /*!< MCO[2:0] bits (Microcontroller Clock Output) */ + + + RCC->CIR = (0 << LSIRDYF) /*!< LSI Ready Interrupt flag */ + |(0 << LSERDYF) /*!< LSE Ready Interrupt flag */ + |(0 << HSIRDYF) /*!< HSI Ready Interrupt flag */ + |(0 << HSERDYF) /*!< HSE Ready Interrupt flag */ + |(0 << PLLRDYF) /*!< PLL Ready Interrupt flag */ + |(0 << CSSF) /*!< Clock Security System Interrupt flag */ + |(0 << LSIRDYIE ) /*!< LSI Ready Interrupt Enable */ + |(0 << LSERDYIE) /*!< LSE Ready Interrupt Enable */ + |(0 << HSIRDYIE) /*!< HSI Ready Interrupt Enable */ + |(0 << HSERDYIE) /*!< HSE Ready Interrupt Enable */ + |(0 << PLLRDYIE) /*!< PLL Ready Interrupt Enable */ + |(0 << LSIRDYC) /*!< LSI Ready Interrupt Clear */ + |(0 << LSERDYC) /*!< LSE Ready Interrupt Clear */ + |(0 << HSIRDYC) /*!< HSI Ready Interrupt Clear */ + |(0 << HSERDYC) /*!< HSE Ready Interrupt Clear */ + |(0 << PLLRDYC) /*!< PLL Ready Interrupt Clear */ + |(0 << CSSC); /*!< Clock Security System Interrupt Clear */ + + + RCC->APB2RSTR = (0 << AFIORST) /*!< Alternate Function I/O reset */ + |(0 << IOPARST) /*!< I/O port A reset */ + |(0 << IOPBRST) /*!< I/O port B reset */ + |(0 << IOPCRST) /*!< I/O port C reset */ + |(0 << IOPDRST) /*!< I/O port D reset */ + |(0 << IOPERST) /*!< I/O port E reset */ + |(0 << IOPFRST) /*!< I/O port F reset */ + |(0 << IOPGRST) /*!< I/O port G reset */ + |(0 << ADC1RST) /*!< ADC 1 interface reset */ + |(0 << ADC2RST) /*!< ADC 2 interface reset */ + |(0 << TIM1RST) /*!< TIM1 Timer reset */ + |(0 << SPI1RST) /*!< SPI 1 reset */ + |(0 << TIM8RST) /*!< TIM8 Timer reset */ + |(0 << USART1RST) /*!< USART1 reset */ + |(0 << ADC3RST); /*!< ADC3 interface reset */ + + RCC->APB1RSTR = (0 << TIM2RST) /*!< Timer 2 reset */ + |(0 << TIM3RST) /*!< Timer 3 reset */ + |(0 << TIM4RST) /*!< Timer 4 reset */ + |(0 << TIM5RST) /*!< Timer 5 reset */ + |(0 << TIM6RST) /*!< Timer 6 reset */ + |(0 << TIM7RST) /*!< Timer 7 reset */ + |(0 << WWDGRST) /*!< Window Watchdog reset */ + |(0 << SPI2RST) /*!< SPI 2 reset */ + |(0 << SPI3RST) /*!< SPI 3 reset */ + |(0 << USART2RST) /*!< USART 2 reset */ + |(0 << USART3RST) /*!< RUSART 3 reset */ + |(0 << UART4RST ) /*!< UART 4 reset */ + |(0 << UART5RST) /*!< UART 5 reset */ + |(0 << I2C1RST) /*!< I2C 1 reset */ + |(0 << I2C2RST) /*!< I2C 2 reset */ + |(0 << USBRST) /*!< USB Device reset */ + |(0 << CAN1RST) /*!< CAN1 reset */ + |(0 << BKPRST) /*!< Backup interface reset */ + |(0 << PWRRST) /*!< Power interface reset */ + |(0 << DACRST); /*!< DAC interface reset */ + + + RCC->AHBENR = (0 << SDIOEN) + |(0 << FSMCEN) + |(0 << CRCEN) + |(1 << FLITFEN) + |(1 << SRAMEN) + |(0 << DMA2EN) + |(1 << DMA1EN); + + RCC->APB1ENR = (0 << DACEN) + |(0 << PWREN) + |(0 << BKPEN) + |(0 << CANEN) + |(0 << USBEN) + |(0 << I2C2EN) + |(0 << I2C1EN) + |(0 << UART5EN) + |(0 << UART4EN) + |(0 << USART3EN) + |(0 << USART2EN) + |(0 << SPI3EN) + |(0 << SPI2EN) + |(0 << WWDGEN) + |(0 << TIM7EN) + |(0 << TIM6EN) + |(0 << TIM5EN) + |(1 << TIM4EN) + |(1 << TIM3EN) + |(1 << TIM2EN); + + RCC->APB2ENR = (0 << ADC3EN) + |(1 << USART1EN) + |(0 << TIM8EN) + |(0 << SPI1EN) + |(1 << TIM1EN) + |(1 << ADC2EN) + |(1 << ADC1EN) + |(0 << IOPGEN) + |(0 << IOPFEN) + |(0 << IOPEEN) + |(1 << IOPDEN) + |(1 << IOPCEN) + |(1 << IOPBEN) + |(1 << IOPAEN) + |(1 << AFIOEN); + + RCC->BDCR = 0x00000000; + RCC->CSR = 0x00000000; + + // Switch to HSE if it is ready + if(BitTest(RCC->CR, (1 << HSERDY))) { + RCC->CFGR &= ~RCC_CFGR_SW; + RCC->CFGR |= RCC_CFGR_SW_HSE; + + // Set PLL source to HSE + RCC->CFGR |= (1 << PLLSRC); + + } + else { + // Use HSI as PLL source + RCC->CFGR &= ~(1 << PLLSRC); + + } + + // Turn on PLL + RCC->CR = (1 << HSION) /*!< Internal High Speed clock enable */ + |(0 << HSIRDY) /*!< Internal High Speed clock ready flag */ + |(0x10 << HSITRIM) /*!< Internal High Speed clock trimming */ + |(0 << HSICAL) /*!< Internal High Speed clock Calibration */ + |(1 << HSEON) /*!< External High Speed clock enable */ + |(0 << HSERDY) /*!< External High Speed clock ready flag */ + |(0 << HSEBYP) /*!< External High Speed clock Bypass */ + |(0 << CSSON) /*!< Clock Security System enable */ + |(1 << PLLON) /*!< PLL enable */ + |(0 << PLLRDY); /*!< PLL clock ready flag */ + + Delay(50000); + + // Switch to PLL if it is ready + if(BitTest(RCC->CR, (1 << PLLRDY))) { + RCC->CFGR &= ~RCC_CFGR_SW; + RCC->CFGR |= RCC_CFGR_SW_PLL; + } + +} + +//----------------------------------------------------------------------------- +// Misc_Init +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// PORT_Init +//----------------------------------------------------------------------------- +// +// +void Port_Init(void) +{ + // Remap to make PB3 & PB4 available + AFIO->MAPR &= ~AFIO_MAPR_SWJ_CFG; + AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_1; + + GPIOA->CRL = ((GPIO_CNF_AnalogIn | GPIO_Mode_In) << (0*4)) // ADC1_IN0 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (1*4)) // Output, SENSEL0 + |((GPIO_CNF_GP_PP |GPIO_Mode_Out50M) << (2*4)) // Output, SENSEL1 + |((GPIO_CNF_GP_PP |GPIO_Mode_Out50M) << (3*4)) // Output, SENSEL2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (4*4)) // Output, SENSEL3 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (5*4)) // Input, CPLSEL + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (6*4)) // Output, TFT_nRD + |((GPIO_CNF_AF_PP | GPIO_Mode_Out50M) << (7*4)); // Output, Test signal + + + GPIOA->CRH = ((GPIO_CNF_Floating| GPIO_Mode_In) << (8 - 8)*4) + |((GPIO_CNF_AF_PP |GPIO_Mode_Out50M) << (9 - 8)*4) // TX1 + |((GPIO_CNF_IPU | GPIO_Mode_In) << (10 - 8)*4) // RX1 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (11 - 8)*4) + |((GPIO_CNF_Floating | GPIO_Mode_In) << (12 - 8)*4) + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (13 - 8)*4) // SWDIO. + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (14 - 8)*4) // SWCLK. + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (15 - 8)*4); // LED + + GPIOA->ODR = 0xFFFF; + + GPIOB->CRL = ((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (0*4)) // TFT port - D0, ENC_A + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (1*4)) // TFT port - D1, ENC_B + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (2*4)) // TFT port - D2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (3*4)) // TFT port - D3, ENC_PB + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (4*4)) // TFT port - D4, SW2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (5*4)) // TFT port - D5, SW3 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (6*4)) // TFT port - D6, SW4 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (7*4)); // TFT port - D7, SW5 + + GPIOB->CRH = ((GPIO_CNF_Floating | GPIO_Mode_In) << ((8 - 8)*4)) + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((9 - 8)*4)) // Output, TFT_nRESET + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((10 - 8)*4)) // SCL + |((GPIO_CNF_Floating | GPIO_Mode_In) << ((11 - 8)*4)) // SDA + |((GPIO_CNF_Floating | GPIO_Mode_In) << ((12 - 8)*4)) // AMPSEL (for test signal) + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((13 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((14 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((15 - 8)*4)); // + + GPIOB->ODR = 0xFFFF; + + GPIOC->CRH = ((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (13 - 8)*4) // TFT_nCS + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (14 - 8)*4) // TFT_RS + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (15 - 8)*4); // TFT_nWR + + GPIOC->ODR = 0xFFFF; + + GPIOD->CRL = ((GPIO_CNF_Floating | GPIO_Mode_In) << (0*4)) + |((GPIO_CNF_Floating | GPIO_Mode_In) << (1*4)); + +} + +void USART1_Init(void) +{ + USART_InitTypeDef USART_InitStructure; + + USART_InitStructure.USART_BaudRate = 38400; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_No; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + + /* Configure USART1 */ + USART_Init(USART1, &USART_InitStructure); + + /* Enable the USART1 */ + USART_Cmd(USART1, ENABLE); + +} + +void UartPutc(U8 ch, USART_TypeDef* USARTx) +{ + while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET) { + } + USART_SendData(USARTx, ch); +} + +void uputs(U8 *s, USART_TypeDef* USARTx) +{ + while(*s != 0) { + UartPutc(*s, USARTx); + s++; + } +} + + void TIM3_Init(void) +{ + // Disable counter first + TIM3->CR1 = (0 << CEN) //!CR2 = (0 << CCPC) //SMCR = (0 << SMS) //DIER = (0 << UIE) //SR = 0x0000; + TIM3->EGR = 0x0000; + +//---------------------------------------------------------------------------- +// TIMx capture/compare usage (x = 2 ~ 5, n = 1 ~ 4) +// +// CCnS[1:0] : +// 00: CCn channel is configured as output. +// 01: CCn channel is configured as input, ICn is mapped on TI1. +// 10: CCn channel is configured as input, ICn is mapped on TI2. +// 11: CCn channel is configured as input, ICn is mapped on TRC. This mode is working only +// if an internal trigger input is selected through TS bit (TIMx_SMCR register) +// Note: CCnS bits are writable only when the channel is OFF (CCnE = 0 in TIMx_CCER). +// Output compare mode +// +// OCnM[2:0] : +// 000: Frozen +// 001: Set channel n to active level on match. +// 010: Set channel n to inactive level on match. +// 011: Toggle - OCnREF toggles when TIMx_CNT=TIMx_CCRn. +// 100: Force inactive level - OCnREF is forced low. +// 101: Force active level - OCnREF is forced high. +// 110: PWM mode 1 - In upcounting, channel n is active as long as TIMx_CNTTIMx_CCRn else active (OCnREF=1). +// 111: PWM mode 2 - In upcounting, channel n is inactive as long as +// TIMx_CNTTIMx_CCRn else inactive. +// Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed +// (LOCK bits in TIMx_BDTR register) and CC1S=00 (the channel is configured in output). +// 2: In PWM mode 1 or 2, the OCREF level changes only when the result of the +// comparison changes or when the output compare mode switches from "frozen" mode +// to "PWM" mode. +// +// ICnPSC[1:0] : +// This bit-field defines the ratio of the prescaler acting on CCn input (ICn). +// The prescaler is reset as soon as CC1E= 0 (TIMx_CCER register). +// 00: no prescaler, capture is done each time an edge is detected on the capture input. +// 01: capture is done once every 2 events. +// 10: capture is done once every 4 events. +// 11: capture is done once every 8 events. +// +// ICnF[3:0] : +// This bit-field defines the frequency used to sample TIn input and the length of the digital +// filter applied to TIn. The digital filter is made of an event counter in which N events are +// needed to validate a transition on the output: +// 0000: No filter, sampling is done at fDTS. +// 0001: fSAMPLING=fCK_INT, N=2. +// 0010: fSAMPLING=fCK_INT, N=4. +// 0011: fSAMPLING=fCK_INT, N=8. +// 0100: fSAMPLING=fDTS/2, N=6. +// 0101: fSAMPLING=fDTS/2, N=8. +// 0110: fSAMPLING=fDTS/4, N=6. +// 0111: fSAMPLING=fDTS/4, N=8. +// 1000: fSAMPLING=fDTS/8, N=6. +// 1001: fSAMPLING=fDTS/8, N=8. +// 1010: fSAMPLING=fDTS/16, N=5. +// 1011: fSAMPLING=fDTS/16, N=6. +// 1100: fSAMPLING=fDTS/16, N=8. +// 1101: fSAMPLING=fDTS/32, N=5. +// 1110: fSAMPLING=fDTS/32, N=6. +// 1111: fSAMPLING=fDTS/32, N=8. +// Note: In current silicon revision, fDTS is replaced in the formula by CK_INT +// when ICnF[3:0]= 1, 2 or 3. +// +// Output compare mode + TIM3->CCMR1 = (0 << CC1S) //!CCMR1 = (0 << CC1S) //!CCMR2 = (0 << CC3S) //!CCMR2 = (0 << CC3S) //!CCER = (0 << CC1E) //CNT = 0x0000; + + TIM3->PSC = 3600 - 1; // 0.5ms clock cycle + + TIM3->ARR = 10 - 1; + + TIM3->CCR1 = 5; + TIM3->CCR2 = 5; + TIM3->CCR3 = 0x0000; + TIM3->CCR4 = 0x0000; + TIM3->DCR = 0x0000; + TIM3->DMAR = 0x0000; + + TIM3->CR1 = (1 << CEN) //VAL = 0; // Write this register will clear itself and the settings in + // SysTick->CTRL + + SysTick->CTRL = (1 << SysTick_ENABLE) + | (1 << SysTick_TICKINT) // Counting down to 0 pends the SysTick handler + | (1 << SysTick_CLKSOURCE) // Clock source. 0 = HCLK/8; 1 = HCLK + | (0 << SysTick_COUNTFLAG); // Count Flag + + SysTick->LOAD = 72000; + +// SysTick->CALRB +// This register is read-only. When clock source is set to HCLK/8 (CLKSOURCE bit is 0) the +// TENMS value in this register will be used to generate 1ms tick. +// + +} + + +void ADC2_Init(void) +{ +// NOTE: Remember to program ADC clock in RCC->CFGR + + ADC2->SR = (0 << AWD) /*!CR1 = (0 << AWDCH) /*!CR2 = (0 << ADON) // /*!SMPR1 = (0 << SMP10) // /*!SMPR2 = (0 << SMP0 ) // /*!JOFR1 = 0x0000; + ADC2->JOFR2 = 0x0000; + ADC2->JOFR3 = 0x0000; + ADC2->JOFR4 = 0x0000; + + ADC2->HTR = 0x0FFF; + ADC2->LTR = 0x0000; + + // L[3:0]: Regular channel sequence length, i.e. number of channels in the sequence. + // These bits are written by software to define the total number of conversions in the regular + // channel conversion sequence. + // 0000: 1 conversion + // 0001: 2 conversions + // ..... + // 1111: 16 conversions + // SQn[4:0]: The order of conversion in regular sequence + // These bits are written by software with the channel number (0..17) assigned as the n-th conversion in the + // sequence to be converted. + // + ADC2->SQR1 = (0 << SQ13 ) // /*!SQR2 = (0 << SQ7) // /*!SQR3 = (0 << SQ1) // /*!JSQR = (0 << JSQ1) // /*!JDR1; +// ADC2->JDR2; +// ADC2->JDR3; +// ADC2->JDR4; +// ADC2->DR; + + // Do calibration + ADC2->CR2 |= (1 << CAL); + while(!BitTest(ADC2->CR2, (1 << CAL))) { + // Wait for end of calibration + } + + // Start ADC (the first ADON set turn on ADC power) + ADC2->CR2 |= (1 << ADON); // /*!SQR3 = (chn << SQ1); // /*!CR2 |= (1 << ADON); + while(!BitTest(adc->SR, (1 << EOC))) { + // Wait for end of conversion + } + return (adc->DR); +} + + +void TFT_Init_Ili9341(void) +{ + U8 tmp; + + // Reset TFT controller (Ili9341) + SetToHigh(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + Delay(5000); // About 1.1ms + SetToLow(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + Delay(65000); // About 15ms + SetToHigh(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + tmp = 10; + while(tmp) { + Delay(65535); + tmp--; + } + + write_comm(0xcf); + write_data(0x00); + write_data(0xC1); + write_data(0x30); + + write_comm(0xed); + write_data(0x67); + write_data(0x03); + write_data(0x12); + write_data(0x81); + + write_comm(0xcb); + write_data(0x39); + write_data(0x2c); + write_data(0x00); + write_data(0x34); + write_data(0x02); + + write_comm(0xea); + write_data(0x00); + write_data(0x00); + + write_comm(0xe8); + write_data(0x85); + write_data(0x0a); + write_data(0x78); + + write_comm(0xF7); + write_data(0x20); + + write_comm(0xC0); //Power control + write_data(0x26); //VRH[5:0] + + write_comm(0xC1); //Power control + write_data(0x01); //SAP[2:0];BT[3:0] + + write_comm(0xC5); //VCM control + write_data(0x2b); + write_data(0x2F); + + write_comm(0xc7); + write_data(0xc7); + + write_comm(0x3A); + write_data(0x55); + + write_comm(0x36); // Memory Access Control +// write_data(0x08); + write_data(0x20); + + write_comm(0xB1); // Frame Rate Control + write_data(0x00); + write_data(0x18); + + write_comm(0xB6); // Display Function Control + write_data(0x0a); +// write_data(0x82); // Normal orientation + write_data(0xE2); // Rotate 180 degree + + write_comm(0xF2); // 3Gamma Function Disable + write_data(0x00); + write_comm(0x26); //Gamma curve selected + write_data(0x01); + write_comm(0xE0); //Set Gamma + write_data(0x0f); + write_data(0x1d); + write_data(0x1a); + write_data(0x09); + write_data(0x0f); + write_data(0x09); + write_data(0x46); + write_data(0x88); + write_data(0x39); + write_data(0x05); + write_data(0x0f); + write_data(0x03); + write_data(0x07); + write_data(0x05); + write_data(0x00); + + write_comm(0XE1); //Set Gamma + write_data(0x00); + write_data(0x22); + write_data(0x25); + write_data(0x06); + write_data(0x10); + write_data(0x06); + write_data(0x39); + write_data(0x22); + write_data(0x4a); + write_data(0x0a); + write_data(0x10); + write_data(0x0c); + write_data(0x38); + write_data(0x3a); + write_data(0x0F); + + write_comm(0x11); //Exit Sleep +// delay(120); + tmp = 100; + while(tmp) { + Delay(50000); + tmp--; + } + write_comm(0x29); //display on +// write_comm(0x2C); + + Delay(50000); + Delay(50000); + +} + + +void write_comm(U8 commport) +{ + // Set TFT_nCS low + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + // Set up to access Index Register (RS == 0) + SetToLow(TFT_RS_Port, (1 << TFT_RS_Bit)); +// Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | commport; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); +// Delay(2); + + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + +} + +void write_data(U8 data) +{ + // Set TFT_nCS low + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + TFT_Port = (TFT_Port & 0xFF00) | data; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + +} + + +U32 TFT_ReadID_Ili9341(void) +{ + U32 tmp; + U8 tmp0, tmp1; + + write_comm(0xD3); + + // Set TFT_nCS low + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + // Set PB[0:7] input mode + GPIOB->CRL = ((GPIO_CNF_Floating | GPIO_Mode_In) << (0*4)) // TFT port - D0 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (1*4)) // TFT port - D1 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (2*4)) // TFT port - D2 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (3*4)) // TFT port - D3 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (4*4)) // TFT port - D4 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (5*4)) // TFT port - D5 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (6*4)) // TFT port - D6 + |((GPIO_CNF_Floating | GPIO_Mode_In) << (7*4)); // TFT port - D7 + Delay(100); + + // Read ID into tmp + tmp0 = 0; + tmp = 0; + while(tmp0 < 4) { + SetToLow(TFT_nRD_Port, (1 << TFT_nRD_Bit)); + Delay(10); + tmp1 = TFT_Port_In; + SetToHigh(TFT_nRD_Port, (1 << TFT_nRD_Bit)); + tmp <<= 8; + tmp |= tmp1; // The first one is dummy read + tmp0++; + } + + // Restore PB[0:7] to output mode + GPIOB->CRL = ((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (0*4)) // TFT port - D0 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (1*4)) // TFT port - D1 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (2*4)) // TFT port - D2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (3*4)) // TFT port - D3 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (4*4)) // TFT port - D4 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (5*4)) // TFT port - D5 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (6*4)) // TFT port - D6 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (7*4)); // TFT port - D7 + + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + + return tmp; + +} + + +void TFT_Init_Ili9325(void) +{ + U16 tmp; + + // Reset TFT controller (Ili9341) + SetToHigh(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + Delay(5000); // About 1.1ms + SetToLow(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + Delay(65000); // About 15ms + tmp = 10; + while(tmp) { + Delay(65535); + tmp--; + } + SetToHigh(TFT_nRESET_Port, (1 << TFT_nRESET_Bit)); + + tmp = 10; + while(tmp) { + Delay(65535); + tmp--; + } + + // Set nCS LOW +// TFT_nCS_Port->BRR |= (1 << TFT_nCS_Bit); + Delay(5000); + +// Normal orientation of screen +// +// ----------------- +// | YU | +// | | +// | | +// | | +// | | +// | | +// | XL XR| +// | | +// | | +// | | +// | | +// | | +// | YD | +// ----------------- +// |||||||||||||| +// |||||||||||||| +// +// Orientation used in this application +// +// --------------------------- +// --| XL | +// --| | +// --| | +// --| | +// --| YD YU | +// --| | +// --| | +// --| XR | +// --------------------------- +/* + LCD_WriteReg(0x00E5,0x78F0); + LCD_WriteReg(0x0001,0x0100); + LCD_WriteReg(0x0002,0x0700); + LCD_WriteReg(0x0003,0x1030); + LCD_WriteReg(0x0004,0x0000); + LCD_WriteReg(0x0008,0x0202); + LCD_WriteReg(0x0009,0x0000); + LCD_WriteReg(0x000A,0x0000); + LCD_WriteReg(0x000C,0x0000); + LCD_WriteReg(0x000D,0x0000); + LCD_WriteReg(0x000F,0x0000); +*/ + + // Start initialization sequence + TFT_CmdWrite(0x00E5, 0x78F0); + TFT_CmdWrite(0x0001, 0x0100); // LCD_Write_Com(0x00,0x01); LCD_Write_Data(0x00,0x00); // set SS=0 and SM bit 0x0100------------- + TFT_CmdWrite(0x0002, 0x0700); // LCD_Write_Com(0x00,0x02); LCD_Write_Data(0x07,0x00); // set 1 line inversion +// TFT_CmdWrite(0x0003, 0x1018); // LCD_Write_Com(0x00,0x03); LCD_Write_Data(0x10,0x28); // 横屏,方向控制 ID=10,AM=1--------------- + TFT_CmdWrite(0x0003, 0x0038); // LCD_Write_Com(0x00,0x03); LCD_Write_Data(0x10,0x28); // 横屏,方向控制 ID=10,AM=1--------------- +// TFT_CmdWrite(0x0003, 0x1030); // //LCD_Write_Com(0x00,0x03); LCD_Write_Data(0x10,0x30); // 竖屏,set GRAM write direction and BGR=1. + TFT_CmdWrite(0x0004, 0x0000); // LCD_Write_Com(0x00,0x04); LCD_Write_Data(0x00,0x00); // Resize register + TFT_CmdWrite(0x0008, 0x0207); // LCD_Write_Com(0x00,0x08); LCD_Write_Data(0x02,0x07); // set the back porch and front porch + TFT_CmdWrite(0x0009, 0x0000); // LCD_Write_Com(0x00,0x09); LCD_Write_Data(0x00,0x00); // set non-display area refresh cycle ISC[3:0] + TFT_CmdWrite(0x000A, 0x0000); // LCD_Write_Com(0x00,0x0A); LCD_Write_Data(0x00,0x00); // FMARK function + TFT_CmdWrite(0x000C, 0x0000); // LCD_Write_Com(0x00,0x0C); LCD_Write_Data(0x00,0x00); // RGB interface setting + TFT_CmdWrite(0x000D, 0x0000); // LCD_Write_Com(0x00,0x0D); LCD_Write_Data(0x00,0x00); // Frame marker Position + TFT_CmdWrite(0x000F, 0x0000); // LCD_Write_Com(0x00,0x0F); LCD_Write_Data(0x00,0x00); // RGB interface polarity + + // Power up sequence + TFT_CmdWrite(0x0010, 0x0000); // LCD_Write_Com(0x00,0x10); LCD_Write_Data(0x00,0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB + TFT_CmdWrite(0x0011, 0x0007); // LCD_Write_Com(0x00,0x11); LCD_Write_Data(0x00,0x07); // DC1[2:0], DC0[2:0], VC[2:0] + TFT_CmdWrite(0x0012, 0x0000); // LCD_Write_Com(0x00,0x12); LCD_Write_Data(0x00,0x00); // VREG1OUT voltage + TFT_CmdWrite(0x0013, 0x0000); // LCD_Write_Com(0x00,0x13); LCD_Write_Data(0x00,0x00); // VDV[4:0] for VCOM amplitude + TFT_CmdWrite(0x0007, 0x0001); // LCD_Write_Com(0x00,0x07); LCD_Write_Data(0x00,0x01); + TFT_CmdWrite(0x0007, 0x0020); // LCD_Write_Com(0x00,0x07); LCD_Write_Data(0x00,0x20); + Delay(50000); // delayms(50); // Dis-charge capacitor power voltage + Delay(50000); + Delay(50000); + TFT_CmdWrite(0x0010, 0x1290); // LCD_Write_Com(0x00,0x10); LCD_Write_Data(0x12,0x90); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB + TFT_CmdWrite(0x0011, 0x0221); // LCD_Write_Com(0x00,0x11); LCD_Write_Data(0x02,0x21); // DC1[2:0], DC0[2:0], VC[2:0] + Delay(50000); // delayms(50);// delayms 50ms + Delay(50000); + Delay(50000); + TFT_CmdWrite(0x0012, 0x0081); // LCD_Write_Com(0x00,0x12); LCD_Write_Data(0x00,0x81); //001C// Internal reference voltage= Vci; + Delay(50000); // delayms(50); // delayms 50ms + Delay(50000); + Delay(50000); + TFT_CmdWrite(0x0013, 0x1500); // LCD_Write_Com(0x00,0x13); LCD_Write_Data(0x15,0x00); //0x1000//1400 Set VDV[4:0] for VCOM amplitude 1A00 + TFT_CmdWrite(0x0029, 0x000C); // LCD_Write_Com(0x00,0x29); LCD_Write_Data(0x00,0x0C); //0x0012 //001a Set VCM[5:0] for VCOMH //0x0025 0034 + TFT_CmdWrite(0x002B, 0x000D); // LCD_Write_Com(0x00,0x2B); LCD_Write_Data(0x00,0x0D); // Set Frame Rate 000C + Delay(50000); // delayms(50);// delayms 50ms + Delay(50000); + Delay(50000); + + TFT_CmdWrite(0x0020, 0x0000); // LCD_Write_Com(0x00,0x20); LCD_Write_Data(0x00,0x00); // GRAM horizontal Address * + TFT_CmdWrite(0x0021, 0x0100); // LCD_Write_Com(0x00,0x21); LCD_Write_Data(0x01,0x00); // GRAM Vertical Address * + + // Adjust the Gamma Curve + TFT_CmdWrite(0x0030, 0x0303); // LCD_Write_Com(0x00,0x30); LCD_Write_Data(0x03,0x03); + TFT_CmdWrite(0x0031, 0x0006); // LCD_Write_Com(0x00,0x31); LCD_Write_Data(0x00,0x06); + TFT_CmdWrite(0x0032, 0x0001); // LCD_Write_Com(0x00,0x32); LCD_Write_Data(0x00,0x01); + TFT_CmdWrite(0x0035, 0x0204); // LCD_Write_Com(0x00,0x35); LCD_Write_Data(0x02,0x04); + TFT_CmdWrite(0x0036, 0x0004); // LCD_Write_Com(0x00,0x36); LCD_Write_Data(0x00,0x04);//0207 + TFT_CmdWrite(0x0037, 0x0407); // LCD_Write_Com(0x00,0x37); LCD_Write_Data(0x04,0x07);//0306 + TFT_CmdWrite(0x0038, 0x0000); // LCD_Write_Com(0x00,0x38); LCD_Write_Data(0x00,0x00);//0102 + TFT_CmdWrite(0x0039, 0x0404); // LCD_Write_Com(0x00,0x39); LCD_Write_Data(0x04,0x04);//0707 + TFT_CmdWrite(0x003C, 0x0402); // LCD_Write_Com(0x00,0x3C); LCD_Write_Data(0x04,0x02);//0702 + TFT_CmdWrite(0x003D, 0x0004); // LCD_Write_Com(0x00,0x3D); LCD_Write_Data(0x00,0x04);//1604 + + // Set GRAM area + TFT_CmdWrite(0x0050, 0x0000); // LCD_Write_Com(0x00,0x50); LCD_Write_Data(0x00,0x00); //00 Horizontal GRAM Start Address* + TFT_CmdWrite(0x0051, 0x00EF); // LCD_Write_Com(0x00,0x51); LCD_Write_Data(0x00,0xEF); //ef Horizontal GRAM End Address * + TFT_CmdWrite(0x0052, 0x0000); // LCD_Write_Com(0x00,0x52); LCD_Write_Data(0x00,0x00); // Vertical GRAM Start Address * + TFT_CmdWrite(0x0053, 0x013F); // LCD_Write_Com(0x00,0x53); LCD_Write_Data(0x01,0x3F); // Vertical GRAM Start Address * + TFT_CmdWrite(0x0060, 0x2700); // LCD_Write_Com(0x00,0x60); LCD_Write_Data(0x27,0x00); // Gate Scan Line GS=0;0xa700------------------ + TFT_CmdWrite(0x0061, 0x0001); // LCD_Write_Com(0x00,0x61); LCD_Write_Data(0x00,0x01); // NDL,VLE, REV + TFT_CmdWrite(0x006A, 0x0000); // LCD_Write_Com(0x00,0x6A); LCD_Write_Data(0x00,0x00); // set scrolling line + + //-------------- Partial Display Control --------- + TFT_CmdWrite(0x0080, 0x0000); // LCD_Write_Com(0x00,0x80); LCD_Write_Data(0x00,0x00); + TFT_CmdWrite(0x0081, 0x0000); // LCD_Write_Com(0x00,0x81); LCD_Write_Data(0x00,0x00); + TFT_CmdWrite(0x0082, 0x0000); // LCD_Write_Com(0x00,0x82); LCD_Write_Data(0x00,0x00); + TFT_CmdWrite(0x0083, 0x0000); // LCD_Write_Com(0x00,0x83); LCD_Write_Data(0x00,0x00); + TFT_CmdWrite(0x0084, 0x0000); // LCD_Write_Com(0x00,0x84); LCD_Write_Data(0x00,0x00); + TFT_CmdWrite(0x0085, 0x0000); // LCD_Write_Com(0x00,0x85); LCD_Write_Data(0x00,0x00); + + //-------------- Panel Control ------------------- + TFT_CmdWrite(0x0090, 0x0010); // LCD_Write_Com(0x00,0x90); LCD_Write_Data(0x00,0x10); + TFT_CmdWrite(0x0092, 0x0600); // LCD_Write_Com(0x00,0x92); LCD_Write_Data(0x06,0x00); + TFT_CmdWrite(0x0007, 0x0133); // LCD_Write_Com(0x00,0x07); LCD_Write_Data(0x01,0x33); // 262K color and display ON + +// LCD_CS_H; + + Delay(50000); + Delay(50000); + Delay(50000); + +} + +// Write Data to Reg in Ili9325 +void TFT_CmdWrite(U16 Reg, U16 Data) +{ + // Set TFT_nCS low + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + // Set up to access Index Register (RS == 0) + SetToLow(TFT_RS_Port, (1 << TFT_RS_Bit)); + Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | (Reg >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | Reg; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | (Data >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | Data; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + +} + +void TFT_AccessGRAM(void) +{ + + // Set TFT_nCS low + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + // Set up to access Index Register (RS == 0) + SetToLow(TFT_RS_Port, (1 << TFT_RS_Bit)); + Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | 0x00; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + Delay(2); + TFT_Port = (TFT_Port & 0xFF00) | 0x22; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + +} + +void TFT_AccessGRAM_End(void) +{ + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); +} + +void assert_failed(U8 * file, U32 line) +//void assert_failed((U8 *) file, U32 line) +{ +} + + +/** + * @brief Configures the nested vectored interrupt controller. + * @param None + * @retval None + */ +void NVIC_Configuration(void) +{ + NVIC_InitTypeDef NVIC_InitStructure; + +// NVIC_SetVectorTable(NVIC_VectTab_RAM, 0); + NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0); + + // Enable the TIM1 Interrupt + NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + + // Enable the ADC1 Interrupt + NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + // Enable the DMA1 channel1 Interrupt + NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + // Enable the USART1 Interrupt + NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + +} + + +void OutputVSen(void) +{ + U16 tmp; + + tmp = (VSenCtrlTab[GetVSen() - VSenMin]) & VSen_Bits; + VSen_Port = (VSen_Port & ~VSen_Bits) | tmp; + +} + +void I2C_Start(void) +{ + SetSDA_Out(); + + SetSDA_H; + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSCL_H; + Delay(I2C_QuadCycle); + SetSDA_L; + Delay(I2C_QuadCycle); + + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSDA_In(); + +} + +void I2C_Stop(void) +{ + SetSDA_Out(); + + SetSDA_L; + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSCL_H; + Delay(I2C_QuadCycle); + SetSDA_H; + Delay(I2C_QuadCycle); + + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSDA_In(); + +} + +void I2C_SendByte(U8 byte) +{ + U8 tmp0; + + SetSDA_Out(); + + tmp0 = 0; + while(tmp0 < 8) { + if(BitTest(byte, 0x80)) { + SetSDA_H; + } + else { + SetSDA_L; + } + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + Delay(I2C_QuadCycle); + SetSCL_L; + if(tmp0 == 7) { + // Last bit + SetSDA_In(); + } + Delay(I2C_QuadCycle); + byte <<= 1; + tmp0++; + } +} + +U8 I2C_RecvByte(void) +{ + U8 tmp0; + U8 byte; + + tmp0 = 0; + while(tmp0 < 8) { + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + byte <<= 1; + if(GetSDA) { + byte |= 0x01; + } + Delay(I2C_QuadCycle); + SetSCL_L; + Delay(I2C_QuadCycle); + tmp0++; + } + return byte; +} + +// Return non-zero if valid ACK detected +U8 I2C_CheckAck(void) +{ + U8 tmp; + + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + tmp = 0x01; + if(GetSDA) { + tmp = 0x00; + } + Delay(I2C_QuadCycle); + SetSCL_L; + Delay(I2C_QuadCycle); + return tmp; + +} + +void I2C_Ack(void) +{ + SetSDA_Out(); + + SetSDA_L; + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + Delay(I2C_QuadCycle); + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSDA_In(); +} + +void I2C_Nak(void) +{ + SetSDA_Out(); + + SetSDA_H; + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + Delay(I2C_QuadCycle); + SetSCL_L; + Delay(I2C_QuadCycle); + + SetSDA_In(); +} + +void I2C_ReSync(void) +{ + U8 tmp0; + + I2C_Start(); + + // 9 cycles of SCL with SDA high + SetSCL_H; + + tmp0 = 0; + while(tmp0 < 9) { + Delay(I2C_QuadCycle); + SetSCL_H; + Delay(I2C_QuadCycle); + Delay(I2C_QuadCycle); + SetSCL_L; + Delay(I2C_QuadCycle); + + tmp0++; + } + + I2C_Start(); + I2C_Stop(); + +} + +void SetSDA_In(void) +{ + I2C_SDA_Port->CRH &= ~(0x000F << (I2C_SDA_Bit - 8) * 4); + I2C_SDA_Port->CRH |= ((GPIO_CNF_Floating | GPIO_Mode_In) << (I2C_SDA_Bit - 8) * 4); +} + +void SetSDA_Out(void) +{ + I2C_SDA_Port->CRH &= ~(0x000F << (I2C_SDA_Bit - 8) * 4); + I2C_SDA_Port->CRH |= (GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (I2C_SDA_Bit - 8) * 4; +} + diff --git a/Board.h b/Board.h new file mode 100644 index 0000000..6f57b16 --- /dev/null +++ b/Board.h @@ -0,0 +1,996 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Board.h +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech Ltd. +// Web: www.jyetech.com +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// +// + +#ifndef Board_h + +#define Board_h + +#include "Common.h" + +#include "stm32f10x.h" +//#include "stm32f10x_conf.h" + +// TFT control ports + +#define TFT_nRESET_Port GPIOB +#define TFT_nRESET_Bit 9 +#define TFT_RS_Port GPIOC +#define TFT_RS_Bit 14 +#define TFT_nCS_Port GPIOC +#define TFT_nCS_Bit 13 +#define TFT_nWR_Port GPIOC +#define TFT_nWR_Bit 15 +#define TFT_nRD_Port GPIOA +#define TFT_nRD_Bit 6 + +#define TFT_Port (GPIOB->ODR) +#define TFT_Port_In (GPIOB->IDR) + +#define LED_Base GPIOA +#define LED_Port (GPIOA->ODR) +#define LED_Bit 15 + +#define Beep_Base (GPIOA) +#define Beep_Port (GPIOA->ODR) +#define Beep_Bit 15 + +#define I2C_SCL_Port GPIOB +#define I2C_SCL_Bit 10 +#define I2C_SDA_Port GPIOB +#define I2C_SDA_Bit 11 + +// I2C Macros +#define SetSCL_H (I2C_SCL_Port->BSRR = 1 << I2C_SCL_Bit) +#define SetSCL_L (I2C_SCL_Port->BRR = 1 << I2C_SCL_Bit) +#define SetSDA_H (I2C_SDA_Port->BSRR = 1 << I2C_SDA_Bit) +#define SetSDA_L (I2C_SDA_Port->BRR = 1 << I2C_SDA_Bit) +#define GetSDA (BitTest(I2C_SDA_Port->IDR, (1 << I2C_SDA_Bit))) + +// Pushbuttons and rotary encoder +#define PB_Port (GPIOB->IDR) +#define PB_Bits 0x00F8 +#define ENC_Port (GPIOB->IDR) +#define ENC_Bits 0x0003 + +// VSen control +#define VSen_Port (GPIOA->ODR) +#define VSen_Bits 0x001E + +// ILI9325 command registers +#define TFT_DriverOutputControl 0x0001 +#define TFT_DrivingWaveControl 0x0002 +#define TFT_EntryMode 0x0003 +#define TFT_DisplayControl1 0x0007 +#define TFT_DisplayControl2 0x0008 +#define TFT_DisplayControl3 0x0009 +#define TFT_DisplayControl4 0x000A +#define TFT_FrameMarkerPosition 0x000D +#define TFT_PowerControl1 0x0010 +#define TFT_PowerControl2 0x0011 +#define TFT_PowerControl3 0x0012 +#define TFT_PowerControl4 0x0013 +#define TFT_DramHAddress 0x0020 +#define TFT_DramVAddress 0x0021 +#define TFT_DramDataWrite 0x0022 +#define TFT_DramDataRead 0x0022 +#define TFT_VCOMH_Control 0x0029 +#define TFT_FrameRateColor 0x002B +#define TFT_HAddressStart 0x0050 +#define TFT_HAddressEnd 0x0051 +#define TFT_VAddressStart 0x0052 +#define TFT_VAddressEnd 0x0053 +#define TFT_GateScanControl1 0x0060 +#define TFT_GateScanControl2 0x0061 +#define TFT_Panel_IF_Control1 0x0090 +#define TFT_Panel_IF_Control2 0x0092 +#define TFT_FAh_FEh_Enable 0x00FF + +// ======== STM32 Register Constants ===================== + +// -------- Register address ----------------- +// RCC registers +#define RCC_AHBENR (*((unsigned int *)(0x40021014))) +#define RCC_APB2ENR (*((unsigned int *)(0x40021018))) +#define RCC_APB1ENR (*((unsigned int *)(0x4002101C))) + +// GPIO registers +#define GPIOA_CRL (*((unsigned int *)(0x40010800))) +#define GPIOA_BSRR (*((unsigned int *)(0x40010810))) +#define GPIOA_BRR (*((unsigned int *)(0x40010814))) + +#define GPIOB_CRL (*((unsigned int *)(0x40010C00))) +#define GPIOB_CRH (*((unsigned int *)(0x40010C04))) +#define GPIOB_IDR (*((unsigned int *)(0x40010C08))) +#define GPIOB_ODR (*((unsigned int *)(0x40010C0C))) +#define GPIOB_BSRR (*((unsigned int *)(0x40010C10))) +#define GPIOB_BRR (*((unsigned int *)(0x40010C14))) +#define GPIOB_LCKR (*((unsigned int *)(0x40010C18))) + +#define GPIOD_CRL (*((unsigned int *)(0x40011400))) +#define GPIOD_CRH (*((unsigned int *)(0x40011404))) +#define GPIOD_IDR (*((unsigned int *)(0x40011408))) +#define GPIOD_ODR (*((unsigned int *)(0x4001140C))) +#define GPIOD_BSRR (*((unsigned int *)(0x40011410))) +#define GPIOD_BRR (*((unsigned int *)(0x40011414))) +#define GPIOD_LCKR (*((unsigned int *)(0x40011418))) + +#define GPIOE_CRL (*((unsigned int *)(0x40011800))) +#define GPIOE_CRH (*((unsigned int *)(0x40011804))) +#define GPIOE_IDR (*((unsigned int *)(0x40011808))) +#define GPIOE_ODR (*((unsigned int *)(0x4001180C))) +#define GPIOE_BSRR (*((unsigned int *)(0x40011810))) +#define GPIOE_BRR (*((unsigned int *)(0x40011814))) +#define GPIOE_LCKR (*((unsigned int *)(0x40011818))) + +// FSMC registers +#define FSMC_BCR1 (*((U32 *)(0xA0000000))) +#define FSMC_BTR1 (*((U32 *)(0xA0000004))) +#define FSMC_BWTR1 (*((U32 *)(0xA0000104))) + +#define FSMC_BCR2 (*((U32 *)(0xA0000008))) +#define FSMC_BTR2 (*((U32 *)(0xA000000C))) +#define FSMC_BWTR2 (*((U32 *)(0xA000010C))) + +// ---------------- Bit fields ------------------------ +// Clock control +//-- AHBENR +#define SDIOEN 10 +#define FSMCEN 8 +#define CRCEN 6 +#define FLITFEN 4 +#define SRAMEN 2 +#define DMA2EN 1 +#define DMA1EN 0 + +//-- APB1ENR +#define DACEN 29 +#define PWREN 28 +#define BKPEN 27 +#define CANEN 25 +#define USBEN 23 +#define I2C2EN 22 +#define I2C1EN 21 +#define UART5EN 20 +#define UART4EN 19 +#define USART3EN 18 +#define USART2EN 17 + +#define SPI3EN 15 +#define SPI2EN 14 +#define WWDGEN 11 +#define TIM7EN 5 +#define TIM6EN 4 +#define TIM5EN 3 +#define TIM4EN 2 +#define TIM3EN 1 +#define TIM2EN 0 + +//-- APB2ENR +#define ADC3EN 15 +#define USART1EN 14 +#define TIM8EN 13 +#define SPI1EN 12 +#define TIM1EN 11 +#define ADC2EN 10 +#define ADC1EN 9 +#define IOPGEN 8 +#define IOPFEN 7 +#define IOPEEN 6 +#define IOPDEN 5 +#define IOPCEN 4 +#define IOPBEN 3 +#define IOPAEN 2 +#define AFIOEN 0 + + +// ---------------- Bit fields ------------------------ +// Clock control +// +/******************** Bit definition for RCC_CR register ********************/ +#define HSION 0 /*!< Internal High Speed clock enable */ +#define HSIRDY 1 /*!< Internal High Speed clock ready flag */ +#define HSITRIM 3 /*!< Internal High Speed clock trimming */ +#define HSICAL 8 /*!< Internal High Speed clock Calibration */ +#define HSEON 16 /*!< External High Speed clock enable */ +#define HSERDY 17 /*!< External High Speed clock ready flag */ +#define HSEBYP 18 /*!< External High Speed clock Bypass */ +#define CSSON 19 /*!< Clock Security System enable */ +#define PLLON 24 /*!< PLL enable */ +#define PLLRDY 25 /*!< PLL clock ready flag */ + +/******************* Bit definition for RCC_CFGR register *******************/ +/*!< SW configuration */ +#define SW 0 /*!< SW[1:0] bits (System clock Switch) */ + +/*!< SWS configuration */ +#define SWS 2 /*!< SWS[1:0] bits (System Clock Switch Status) */ + +/*!< HPRE configuration */ +#define HPRE 4 /*!< HPRE[3:0] bits (AHB prescaler) */ + +/*!< PPRE1 configuration */ +#define PPRE1 8 /*!< PRE1[2:0] bits (APB1 prescaler) */ + +/*!< PPRE2 configuration */ +#define PPRE2 11 /*!< PRE2[2:0] bits (APB2 prescaler) */ + +/*!< ADCPPRE configuration */ +#define ADCPRE 14 /*!< ADCPRE[1:0] bits (ADC prescaler) */ + +#define PLLSRC 16 /*!< PLL entry clock source */ + +#define PLLXTPRE 17 /*!< HSE divider for PLL entry */ + +/*!< PLLMUL configuration */ +#define PLLMULL 18 /*!< PLLMUL[3:0] bits (PLL multiplication factor) */ + + #define USBPRE 22 /*!< USB Device prescaler */ + +/*!< MCO configuration */ +#define MCO 24 /*!< MCO[2:0] bits (Microcontroller Clock Output) */ + +/*!<****************** Bit definition for RCC_CIR register ********************/ +#define LSIRDYF 0 /*!< LSI Ready Interrupt flag */ +#define LSERDYF 1 /*!< LSE Ready Interrupt flag */ +#define HSIRDYF 2 /*!< HSI Ready Interrupt flag */ +#define HSERDYF 3 /*!< HSE Ready Interrupt flag */ +#define PLLRDYF 4 /*!< PLL Ready Interrupt flag */ +#define CSSF 7 /*!< Clock Security System Interrupt flag */ +#define LSIRDYIE 8 /*!< LSI Ready Interrupt Enable */ +#define LSERDYIE 9 /*!< LSE Ready Interrupt Enable */ +#define HSIRDYIE 10 /*!< HSI Ready Interrupt Enable */ +#define HSERDYIE 11 /*!< HSE Ready Interrupt Enable */ +#define PLLRDYIE 12 /*!< PLL Ready Interrupt Enable */ +#define LSIRDYC 16 /*!< LSI Ready Interrupt Clear */ +#define LSERDYC 17 /*!< LSE Ready Interrupt Clear */ +#define HSIRDYC 18 /*!< HSI Ready Interrupt Clear */ +#define HSERDYC 19 /*!< HSE Ready Interrupt Clear */ +#define PLLRDYC 20 /*!< PLL Ready Interrupt Clear */ +#define CSSC 23 /*!< Clock Security System Interrupt Clear */ + +/***************** Bit definition for RCC_APB2RSTR register *****************/ +#define AFIORST 0 /*!< Alternate Function I/O reset */ +#define IOPARST 2 /*!< I/O port A reset */ +#define IOPBRST 3 /*!< I/O port B reset */ +#define IOPCRST 4 /*!< I/O port C reset */ +#define IOPDRST 5 /*!< I/O port D reset */ +#define IOPERST 6 /*!< I/O port E reset */ +#define IOPFRST 7 /*!< I/O port F reset */ +#define IOPGRST 8 /*!< I/O port G reset */ +#define ADC1RST 9 /*!< ADC 1 interface reset */ +#define ADC2RST 10 /*!< ADC 2 interface reset */ +#define TIM1RST 11 /*!< TIM1 Timer reset */ +#define SPI1RST 12 /*!< SPI 1 reset */ +#define TIM8RST 13 /*!< TIM8 Timer reset */ +#define USART1RST 14 /*!< USART1 reset */ +#define ADC3RST 15 /*!< ADC3 interface reset */ + +/***************** Bit definition for RCC_APB1RSTR register *****************/ +#define TIM2RST 0 /*!< Timer 2 reset */ +#define TIM3RST 1 /*!< Timer 3 reset */ +#define TIM4RST 2 /*!< Timer 4 reset */ +#define TIM5RST 3 /*!< Timer 5 reset */ +#define TIM6RST 4 /*!< Timer 6 reset */ +#define TIM7RST 5 /*!< Timer 7 reset */ +#define WWDGRST 11 /*!< Window Watchdog reset */ +#define SPI2RST 14 /*!< SPI 2 reset */ +#define SPI3RST 15 /*!< SPI 3 reset */ +#define USART2RST 17 /*!< USART 2 reset */ +#define USART3RST 18 /*!< RUSART 3 reset */ +#define UART4RST 19 /*!< UART 4 reset */ +#define UART5RST 20 /*!< UART 5 reset */ +#define I2C1RST 21 /*!< I2C 1 reset */ +#define I2C2RST 22 /*!< I2C 2 reset */ +#define USBRST 23 /*!< USB Device reset */ +#define CAN1RST 25 /*!< CAN1 reset */ +#define BKPRST 27 /*!< Backup interface reset */ +#define PWRRST 28 /*!< Power interface reset */ +#define DACRST 29 /*!< DAC interface reset */ + +/****************** Bit definition for RCC_AHBENR register ******************/ +#define DMA1EN 0 /*!< DMA1 clock enable */ +#define DMA2EN 1 /*!< DMA2 clock enable */ +#define SRAMEN 2 /*!< SRAM interface clock enable */ +#define FLITFEN 4 /*!< FLITF clock enable */ +#define CRCEN 6 /*!< CRC clock enable */ +#define FSMCEN 8 /*!< FSMC clock enable */ +#define SDIOEN 10 /*!< SDIO clock enable */ + +/****************** Bit definition for RCC_APB2ENR register *****************/ +#define AFIOEN 0 /*!< Alternate Function I/O clock enable */ +#define IOPAEN 2 /*!< I/O port A clock enable */ +#define IOPBEN 3 /*!< I/O port B clock enable */ +#define IOPCEN 4 /*!< I/O port C clock enable */ +#define IOPDEN 5 /*!< I/O port D clock enable */ +#define IOPEEN 6 /*!< I/O port E clock enable */ +#define IOPFEN 7 /*!< I/O port F clock enable */ +#define IOPGEN 8 /*!< I/O port G clock enable */ +#define ADC1EN 9 /*!< ADC 1 interface clock enable */ +#define ADC2EN 10 /*!< ADC 2 interface clock enable */ +#define TIM1EN 11 /*!< TIM1 Timer clock enable */ +#define SPI1EN 12 /*!< SPI 1 clock enable */ +#define TIM8EN 13 /*!< TIM8 Timer clock enable */ +#define USART1EN 14 /*!< USART1 clock enable */ +#define ADC3EN 15 /*!< DMA1 clock enable */ + +/***************** Bit definition for RCC_APB1ENR register ******************/ +#define TIM2EN 0 /*!< Timer 2 clock enabled*/ +#define TIM3EN 1 /*!< Timer 3 clock enable */ +#define TIM4EN 2 /*!< Timer 4 clock enable */ +#define TIM5EN 3 /*!< Timer 5 clock enable */ +#define TIM6EN 4 /*!< Timer 6 clock enable */ +#define TIM7EN 5 /*!< Timer 7 clock enable */ +#define WWDGEN 11 /*!< Window Watchdog clock enable */ +#define SPI2EN 14 /*!< SPI 2 clock enable */ +#define SPI3EN 15 /*!< SPI 3 clock enable */ +#define USART2EN 17 /*!< USART 2 clock enable */ +#define USART3EN 18 /*!< USART 3 clock enable */ +#define UART4EN 19 /*!< UART 4 clock enable */ +#define UART5EN 20 /*!< UART 5 clock enable */ +#define I2C1EN 21 /*!< I2C 1 clock enable */ +#define I2C2EN 22 /*!< I2C 2 clock enable */ +#define USBEN 23 /*!< USB Device clock enable */ +#define CAN1EN 25 /*!< CAN1 clock enable */ +#define BKPEN 27 /*!< Backup interface clock enable */ +#define PWREN 28 /*!< Power interface clock enable */ +#define DACEN 29 /*!< DAC interface clock enable */ + + +/******************* Bit definition for RCC_BDCR register *******************/ +#define LSEON 0 /*!< External Low Speed oscillator enable */ +#define LSERDY 1 /*!< External Low Speed oscillator Ready */ +#define LSEBYP 2 /*!< External Low Speed oscillator Bypass */ + +#define RTCSEL 8 /*!< RTCSEL[1:0] bits (RTC clock source selection) */ + +#define RTCEN 15 /*!< RTC clock enable */ +#define BDRST 16 /*!< Backup domain software reset */ + +/******************* Bit definition for RCC_CSR register ********************/ +#define LSION 0 /*!< Internal Low Speed oscillator enable */ +#define LSIRDY 1 /*!< Internal Low Speed oscillator Ready */ +#define RMVF 24 /*!< Remove reset flag */ +#define PINRSTF 26 /*!< PIN reset flag */ +#define PORRSTF 27 /*!< POR/PDR reset flag */ +#define SFTRSTF 28 /*!< Software Reset flag */ +#define IWDGRSTF 29 /*!< Independent Watchdog reset flag */ +#define WWDGRSTF 30 /*!< Window watchdog reset flag */ +#define LPWRRSTF 31 /*!< Low-Power reset flag */ + +/******************************************************************************/ +/* */ +/* TIM */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for TIM_CR1 register ********************/ +#define CEN 0 /*!CRH = ((GPIO_CNF_AF_PP | GPIO_Mode_Out50M) << ((8 - 8)*4)) // Output, Trigger level + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((9 - 8)*4)) // Output, TFT_nRESET + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((10 - 8)*4)) // SCL + |((GPIO_CNF_Floating | GPIO_Mode_In) << ((11 - 8)*4)) // SDA + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((12 - 8)*4)) // AMPSEL (for test signal) + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((13 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((14 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((15 - 8)*4)); // + // GPIOB->ODR &= ~(1 << 12); + Port_BitClr(GPIOB, (1 << 12)); + } + else { + // Set to 3.3V + GPIOB->CRH = ((GPIO_CNF_AF_PP | GPIO_Mode_Out50M) << ((8 - 8)*4)) // Output, Trigger level + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((9 - 8)*4)) // Output, TFT_nRESET + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << ((10 - 8)*4)) // SCL + |((GPIO_CNF_Floating | GPIO_Mode_In) << ((11 - 8)*4)) // SDA + |((GPIO_CNF_Floating | GPIO_Mode_In) << ((12 - 8)*4)) // AMPSEL (for test signal) + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((13 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((14 - 8)*4)) // + |((GPIO_CNF_IPU | GPIO_Mode_In) << ((15 - 8)*4)); // + } + } + break; + + case KC_ENC_PBH: + BitXor(AddOns, (1 << AO_TestSigAmpDisp)); + if(!BitTest(AddOns, (1 << AO_TestSigAmpDisp))) { + // Clear amp display + FillRect(TestSigAmpx0, TestSigAmpy0, 14 * 8, 16, clBlack); + } + break; + } +} + + +void KeyScan(void) +{ + U16 tmp1, tmp4; + U8 tmp2, tmp3; + + Keypad.KScanBuf = NoKey; + // Set keypad ports to input with pull-ups + GPIOB->CRL = ((GPIO_CNF_IPU | GPIO_Mode_In) << (0*4)) // TFT port - D0, ENC_A + |((GPIO_CNF_IPU | GPIO_Mode_In) << (1*4)) // TFT port - D1, ENC_B + |((GPIO_CNF_IPU | GPIO_Mode_In) << (2*4)) // TFT port - D2 + |((GPIO_CNF_IPU | GPIO_Mode_In) << (3*4)) // TFT port - D3, ENC_PB + |((GPIO_CNF_IPU | GPIO_Mode_In) << (4*4)) // TFT port - D4, SW2 + |((GPIO_CNF_IPU | GPIO_Mode_In) << (5*4)) // TFT port - D5, SW3 + |((GPIO_CNF_IPU | GPIO_Mode_In) << (6*4)) // TFT port - D6, SW4 + |((GPIO_CNF_IPU | GPIO_Mode_In) << (7*4)); // TFT port - D7, SW5 + Delay(10); + + // Read buttons + tmp1 = (PB_Port & PB_Bits) | ~PB_Bits; + tmp4 = ENC_Port & ENC_Bits; + + // Restore + GPIOB->CRL = ((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (0*4)) // TFT port - D0, ENC_A + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (1*4)) // TFT port - D1, ENC_B + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (2*4)) // TFT port - D2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (3*4)) // TFT port - D3, ENC_PB + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (4*4)) // TFT port - D4, SW2 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (5*4)) // TFT port - D5, SW3 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (6*4)) // TFT port - D6, SW4 + |((GPIO_CNF_GP_PP | GPIO_Mode_Out50M) << (7*4)); // TFT port - D7, SW5 + + if(tmp1 != NoKey) { + BitSet(Keypad.Flags, (1 << KF_KeyHit)); + Keypad.KScanBuf = tmp1; + } + + // -- Debouncing + if((Keypad.KScanBuf == NoKey) || (Keypad.KScanBuf != Keypad.KScanCode)) { + if(BitSet(Keypad.Flags, (1 << KF_PressDetected))) { + KeyConvert((KeyScanCode *)KScanCodeTab, Keypad.KScanCode); + BitClr(Keypad.Flags, (1 << KF_PressDetected)); + } + Keypad.KScanCode = Keypad.KScanBuf; + Keypad.KCount = 0; + Keypad.KHCount = 0; + Keypad.KTimeChk = KH_val; + BitClr(Keypad.Flags, (1 << KF_HoldDetected)); + } + else { + Keypad.KCount++; + if(Keypad.KCount > Keypad.KDebounceVal) { + if(Keypad.KCount == Keypad.KDebounceVal + 3) { + Keypad.KCount = Keypad.KDebounceVal; + if(++Keypad.KHCount == Keypad.KTimeChk) { + // Key hold detected + BitClr(Keypad.Flags, (1 << KF_PressDetected)); + if(!BitTest(Keypad.Flags, (1 << KF_HoldDetected))) { + KeyConvert((KeyScanCode *)KScanCodeTab, Keypad.KScanCode & 0xFFFE); + BitSet(Keypad.Flags, (1 << KF_HoldDetected)); + Keypad.KTimeChk += 20; + } + else { + KeyConvert((KeyScanCode *)KScanCodeTab, Keypad.KScanCode); + // Change KTimeChk for key repeat + Keypad.KTimeChk += KR_Time; + } + } + } + } + else if(Keypad.KCount == Keypad.KDebounceVal) { + // Key push detected + BitSet(Keypad.Flags, (1 << KF_PressDetected)); + } + } + + // Process encoder + Keypad.EncState <<= 2; + Keypad.EncState |= tmp4; + tmp1 = enc_table[Keypad.EncState & 0x000F]; + if(tmp1 == 1) { + Keypad.KeyCode = KC_ENC_CCW; + Keypad.KeyParam = 0; + } + if(tmp1 == 0xFF) { + Keypad.KeyCode = KC_ENC_CW; + Keypad.KeyParam = 1; + } + +#define Threshold_High 0x0900 +#define Threshold_Low 0x0300 + + // Read switch Cpl + tmp1 = ADC_Poll(ADC2, 5); + tmp2 = 0; + if(tmp1 > Threshold_High) { + tmp2 = 1; + } + else if(tmp1 < Threshold_Low) { + tmp2 = 2; + } + + // Determine Cpl setting + if(tmp2 != CplPrev) { + SetCpl(tmp2); + CplPrev = tmp2; + UpdateDisp(Disp_Param); + } + } + +void KeyConvert(KeyScanCode *KSCTab, U16 KSCode) +{ + U16 tmp1; + + while((tmp1 = *(U16 *)(KSCTab + 0))) { + if(tmp1 == KSCode) { + // -- Match found + Keypad.KeyCode = *(U8 *)((U8 *)KSCTab + 2); + Keypad.KeyCodeBuf = Keypad.KeyCode; + Keypad.KeyParam = *(U8 *)((U8 *)KSCTab + 3); + return; + } + else { + // -- Proceed to next entry + KSCTab = (KeyScanCode *)((U8 *)KSCTab + sizeof(KeyScanCode)); + } + + } +} + +void DoKeyOk(void) +{ + U8 tmp; + U8 tmpbuf[33]; + U32 tmp1; + + tmp = GetDsoStatus(); + // Toggle HOLD state + BitXor(tmp, DSO_Hold); + + if(BitTest(tmp, DSO_Hold)) { + // Set HOLD + SetHold(); + // Stop capture + StopCapture(); + } + else { + // Clear HOLD + ClrHold(); + // Start capture at exit of HOLD + StartCapture(); + } + + UpdateDisp(Disp_Param); +} + +void DoKeyInc(void) +{ + S8 tmp0; + S16 tmp1; + + switch(GetFocus()) { + case FC_VSen: + tmp0 = GetVSen(); + tmp0++; + tmp0 = SetVSen(tmp0); + OutputVSen(); + EE_WriteVariable(VirtAddVarTab[Addr_Vsen], tmp0); + // Update VPos offset + EE_ReadVariable(VirtAddVarTab[Addr_VPosOfs00 + (tmp0 - VSenMin)], &tmp1); + SetVPosOfs(tmp1); + break; + + case FC_Timebase: + tmp0 = GetTimebase(); + tmp0++; + tmp0 = SetTimeBase(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TimeBase], tmp0); + if(tmp0 >= TB_20ms) { + // Restart capture + StartCapture(); + } + else { + // Change sampling rate only + UpdateTimebase(); + } + // Make key debounce time shorter for these TB's + if((tmp0 < TB_20ms) && (tmp0 > TB_1s)) { + Keypad.KDebounceVal = KD_val1; + } + else { + Keypad.KDebounceVal = KD_val; + } + default: + break; + + case FC_TrigMode: + tmp0 = GetTrigMode(); + tmp0++; + tmp0 = SetTrigMode(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TrigMode], tmp0); + // Restart capture. + StartCapture(); + break; + + case FC_TrigEdge: + tmp0 = GetTrigEdge(); + tmp0++; + tmp0 = SetTrigEdge(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TrigEdge], tmp0); + break; + + case FC_VPos: + tmp1 = GetVPos(); + tmp1++; + tmp1 = SetVPos(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_Vpos], tmp1); + UpdateDisp(Disp_Trace); + break; + + case FC_TrigLvl: + tmp1 = GetTrigLvl(); + tmp1 += 2; + tmp1 = SetTrigLvl(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_TrigLvl], tmp1); +// OutputTLvl(); + break; + + case FC_HPos: + // Move waveform right + tmp1 = GetHPos(); + tmp1--; + tmp1 = SetHPos(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_HPos], tmp1); + UpdateDisp(Disp_Trace); + break; + + } + + UpdateDisp(Disp_Param); +} + +void DoKeyDec(void) +{ + S8 tmp0; + S16 tmp1; + + switch(GetFocus()) { + case FC_VSen: + tmp0 = GetVSen(); + tmp0--; + tmp0 = SetVSen(tmp0); + OutputVSen(); + EE_WriteVariable(VirtAddVarTab[Addr_Vsen], tmp0); + // Update VPos offset + EE_ReadVariable(VirtAddVarTab[Addr_VPosOfs00 + (tmp0 - VSenMin)], &tmp1); + SetVPosOfs(tmp1); + break; + + case FC_Timebase: + tmp0 = GetTimebase(); + tmp0--; + tmp0 = SetTimeBase(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TimeBase], tmp0); + if(tmp0 >= TB_50ms) { + // Restart capture + StartCapture(); + } + else { + // Change sampling rate only + UpdateTimebase(); + + } + + default: + break; + + case FC_TrigMode: + tmp0 = GetTrigMode(); + tmp0--; + tmp0 = SetTrigMode(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TrigMode], tmp0); + // Restart capture. + StartCapture(); + break; + + case FC_TrigEdge: + tmp0 = GetTrigEdge(); + tmp0--; + tmp0 = SetTrigEdge(tmp0); + EE_WriteVariable(VirtAddVarTab[Addr_TrigEdge], tmp0); + break; + + case FC_VPos: + tmp1 = GetVPos(); + tmp1--; + tmp1 = SetVPos(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_Vpos], tmp1); + UpdateDisp(Disp_Trace); + break; + + case FC_TrigLvl: + tmp1 = GetTrigLvl(); + tmp1 -= 2; + tmp1 = SetTrigLvl(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_TrigLvl], tmp1); +// OutputTLvl(); + break; + + case FC_HPos: + // Move waveform left + tmp1 = GetHPos(); + tmp1++; + tmp1 = SetHPos(tmp1); + EE_WriteVariable(VirtAddVarTab[Addr_HPos], tmp1); + UpdateDisp(Disp_Trace); + break; + + } + + UpdateDisp(Disp_Param); +} + +void DoKeyOkH(void) +{ + + BitXor(AddOns, (1 << AO_MeasurementOn)); + EE_WriteVariable(VirtAddVarTab[Addr_AddOns], AddOns); + if(!BitTest(AddOns, (1 << AO_MeasurementOn))) { + // Clear + FillRect(VoltageReadingx0, VoltageReadingy0, 100, 80, clBlack); + FillRect(FreqReadingx0, FreqReadingy0, 140, 70, clBlack); + } +} + +void DoKeyIncH(void) +{ + S16 tmp1; + + switch(GetFocus()) { + case FC_VPos: + tmp1 = GetVPos(); + tmp1 += 10; + SetVPos(tmp1); + break; + + case FC_TrigLvl: + tmp1 = GetTrigLvl(); + tmp1 += 40; + SetTrigLvl(tmp1); + break; + + case FC_HPos: + // Move waveform right + tmp1 = GetHPos(); + tmp1 -= 20; + SetHPos(tmp1); + break; + } + + UpdateDisp(Disp_Param); +} + +void DoKeyDecH(void) +{ + S16 tmp1; + + switch(GetFocus()) { + case FC_VPos: + tmp1 = GetVPos(); + tmp1 -= 10; + SetVPos(tmp1); + break; + + case FC_TrigLvl: + tmp1 = GetTrigLvl(); + tmp1 -= 40; + SetTrigLvl(tmp1); + break; + + case FC_HPos: + // Move waveform left + tmp1 = GetHPos(); + tmp1 += 20; + SetHPos(tmp1); + break; + } + + UpdateDisp(Disp_Param); +} + +void DoKeySelH(void) +{ +} + +void SelVertical(void) +{ + U8 tmp; + + tmp = GetFocus(); + if(tmp != FC_VSen) { + tmp = FC_VSen; + } + else { + tmp = FC_VPos; + } + + SetFocus(tmp); + UpdateDisp(Disp_Param); +} + +void SelHorzontal(void) +{ + U8 tmp; + + tmp = GetFocus(); + if(tmp != FC_Timebase) { + tmp = FC_Timebase; + } + else { + tmp = FC_HPos; + } + + SetFocus(tmp); + UpdateDisp(Disp_Param); +} + +void SelTrigger(void) +{ + U8 tmp; + + tmp = GetFocus(); + switch(tmp) { + case FC_TrigMode: + tmp = FC_TrigLvl; + break; + + case FC_TrigEdge: + tmp = FC_TrigMode; + break; + + case FC_TrigLvl: + tmp = FC_TrigEdge; + break; + + default: + tmp = FC_TrigMode; + } + + SetFocus(tmp); + UpdateDisp(Disp_Param); +} + +void VPosAlign(void) +{ + S16 tmp1; + S8 tmp2, tmp3, tmp4, tmp5; + + // Do VPos alignment + + // Set timebase to 1ms so as the calibration won't take too long + // Set trigger mode to AUTO + tmp3 = GetTimebase(); + tmp4 = GetVSen(); + tmp5 = GetTrigMode(); + + SetTimeBase(TB_1ms); + SetTrigMode(TM_Auto); + + // Make sure the current VPosOfs is zero + SetVPosOfs(0); + + // Do alignment for each VSen setting + tmp2 = VSenMin; + while(tmp2 <= VSenMax) { + SetVSen(tmp2); + OutputVSen(); + Delay(60000); + StartCapture(); + tmp1 = 0; + while(!BitTest(tmp1, DSO_CaptureDone)) { + tmp1 = GetDsoStatus(); + } + tmp1 = (S16)(GetAverage() - SampleMidValue); + EE_WriteVariable(VirtAddVarTab[Addr_VPosOfs00 + (tmp2 - VSenMin)], tmp1); + tmp2++; + } + + // Restore settings + SetTimeBase(tmp3); + SetVSen(tmp4); + SetTrigMode(tmp5); + OutputVSen(); + // Setup current VPos offset + EE_ReadVariable(VirtAddVarTab[Addr_VPosOfs00 + (tmp4 - VSenMin)], &tmp1); + SetVPosOfs(tmp1); + +} + +void CenterHPos(void) +{ + // Set HPos to center + SetHPos((GetRecLen() - WWindowSizex)/2); + UpdateDisp(Disp_Param); +} + +void CenterTrigLevel(void) +{ + S16 tmp1; + + // Set trigger level to the middle of signal amplitude + tmp1 = ((Vmax + Vmin)/2) + 2 * GetVPosOfs(); + SetTrigLvl(tmp1); + UpdateDisp(Disp_Param); +} + +void LedBlink(void) +{ + U16 tmp; + + // Turn on LED + Port_BitClr(LED_Base, (1 << LED_Bit)); + tmp = 50; + while(tmp) { + Delay(65000); + tmp--; + } + + // Turn off LED + Port_BitSet(LED_Base, (1 << LED_Bit)); + tmp = 50; + while(tmp) { + Delay(65000); + tmp--; + } + + // Turn on LED + Port_BitClr(LED_Base, (1 << LED_Bit)); + tmp = 50; + while(tmp) { + Delay(65000); + tmp--; + } + + // Turn off LED + Port_BitSet(LED_Base, (1 << LED_Bit)); +} + +void LedBlink_Fast(void) +{ + U16 tmp; + + while(1) { + // Turn on LED + Port_BitClr(LED_Base, (1 << LED_Bit)); + tmp = 1; + while(tmp) { + Delay(65000); + tmp--; + } + + // Turn off LED + Port_BitSet(LED_Base, (1 << LED_Bit)); + tmp = 1; + while(tmp) { + Delay(65000); + tmp--; + } + } +} + +void SaveWaveform(void) +{ + U16 tmp0, tmp1, tmp2; + U16 *ptmp1; + + // Display message + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Saving ", clOrange, clBlack, &ASC8X16); + + FLASH_Unlock(); + + // Erase buffer + tmp2 = FLASH_ErasePage(Waveform_START_ADDRESS); + if(tmp2 != FLASH_COMPLETE) { + // Failed + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Failed1", clRed, clBlack, &ASC8X16); + goto Failure; + } + tmp2 = FLASH_ErasePage(Waveform_START_ADDRESS + 0x0400); + if(tmp2 != FLASH_COMPLETE) { + // Failed + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Failed1", clRed, clBlack, &ASC8X16); + goto Failure; + } + tmp2 = FLASH_ErasePage(Parameter_START_ADDRESS); + if(tmp2 != FLASH_COMPLETE) { + // Failed + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Failed2", clRed, clBlack, &ASC8X16); + goto Failure; + } + + // Save waveform data + ptmp1 = SampleBuf; + tmp1 = GetRecLen(); + tmp0 = 0; + while(tmp0 < tmp1) { + tmp2 = FLASH_ProgramHalfWord(Waveform_START_ADDRESS + tmp0 * 2, *ptmp1); + if(tmp2 != FLASH_COMPLETE) { + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Failed3", clRed, clBlack, &ASC8X16); + goto Failure; + } + // Proceed to next sample + ptmp1++; + tmp0++; + } + + // Save parameters + ptmp1 = ReadingStr; + *ptmp1++ = (U16)GetRecLen(); + *ptmp1++ = (U16)GetVSen(); + *ptmp1++ = (U16)GetCpl(); + *ptmp1++ = (U16)GetTimebase(); + *ptmp1++ = (U16)GetTrigMode(); + *ptmp1++ = (U16)GetTrigEdge(); + *ptmp1++ = (U16)GetTrigLvl(); + *ptmp1++ = (U16)GetHPos(); + *ptmp1++ = (U16)GetVPos(); + *ptmp1++ = (U16)GetVPosOfs(); + + ptmp1 = ReadingStr; + tmp1 = 10; + tmp0 = 0; + while(tmp0 < tmp1) { + tmp2 = FLASH_ProgramHalfWord(Parameter_START_ADDRESS + tmp0 * 2, *ptmp1); + if(tmp2 != FLASH_COMPLETE) { + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Failed4", clRed, clBlack, &ASC8X16); + goto Failure; + } + // Proceed to next sample + ptmp1++; + tmp0++; + } + + // Return to normal running + UpdateDisp(Disp_Param); + return; + + Failure: + UartPutc(0xFA, USART1); + UartPutc(tmp2 >> 8, USART1); + UartPutc(tmp2, USART1); + UartPutc(0xF0, USART1); + UartPutc(tmp0 >> 8, USART1); + UartPutc(tmp0, USART1); + + while(1); +} + +void LoadWaveform(void) +{ + U16 tmp0, tmp1; + U16 *ptmp1, *ptmp2; + + // Display message + PutsGenic(WWindowx0 + 4, WWindowy0 -17, (U8 *)"Loading", clOrange, clBlack, &ASC8X16); + + // Load parameters + ptmp2 = Parameter_START_ADDRESS; + SetRecLen(*ptmp2++); + SetVSen((S8)*ptmp2++); + SetCpl((S8)*ptmp2++); + SetTimeBase((S8)*ptmp2++); + SetTrigMode((S8)*ptmp2++); + SetTrigEdge((S8)*ptmp2++); + SetTrigLvl((S16)*ptmp2++); + SetHPos((S16)*ptmp2++); + SetVPos((S16)*ptmp2++); + SetVPosOfs((S16)*ptmp2++); + + // Load waveform data to SamBuffer + ptmp1 = SampleBuf; + ptmp2 = (U16 *)Waveform_START_ADDRESS; + tmp1 = GetRecLen(); + tmp0 = 0; + while(tmp0 < tmp1) { + *ptmp1++ = *ptmp2++; + tmp0++; + } + + // Enter HOLD + SetHold(); + // Stop capture + StopCapture(); + + // Display + UpdateDisp(Disp_Param); + UpdateDisp(Disp_Trace); + +} + +// --------------------------------------------------------------- +// Note: Freq and duty measurement produce large errors for timebase >= 20us. +// This is because interpolation has been used for these timebases. + +#define LevelSen 16 // Sensitivity of level + +void Measurements(void) +{ + S32 sum, bufsize, index, rms; + S16 vmax, vmin, v0; + S16 tmp; + S16 currentstate; + S32 fallingcnt, risingcnt; + S32 fallingtime, risingtime, highleveltime; + S16 HighLevel, LowLevel; + S32 firstfalling, firstrising; // Keep the start of valid samples + + // Initialization for voltage measurement + vmax = 0; + vmin = 0xFFF; + sum = 0; + rms = 0; + v0 = GetVPosOfs(); // + + bufsize = GetRecLen(); + index = 0; + while(index < bufsize) { + // Get a sample + tmp = *(SampleBuf + index); + + // Searching for Vmax + if(tmp > vmax) { + vmax = tmp; + } + + // Searching for Vmin + if(tmp < vmin) { + vmin = tmp; + } + + // Calculate sum + sum += tmp; + + // Calculate rms + rms += ((S32)(tmp - SampleMidValue) * (S32)(tmp - SampleMidValue)); + + index++; + } + + BitSet(Flags, (1 << Flag_VoltValid)); + if((vmax > 0x0FFC) || (vmin < 0x0004)) { + BitClr(Flags, (1 << Flag_VoltValid)); + } + + Vmax = vmax - SampleMidValue; + Vmin = vmin - SampleMidValue; + Vavr = (sum/bufsize) - SampleMidValue; + Vpp = vmax - vmin; + Vrms = (S16)(sqrt((float)rms/(float)bufsize)); + + // Initialization for freq, Cycle, and duty measurement + v0 = (sum/bufsize); + fallingcnt = 0; + risingcnt = 0; + HighLevel = v0 + LevelSen/2; + LowLevel = v0 - LevelSen/2; + v0 = GetVPosOfs(); // + currentstate = ((*SampleBuf - v0) >= SampleMidValue) ? 1 : 0; + highleveltime = 0; + + index = 0; + while(index < bufsize) { + // Get a sample + tmp = *(SampleBuf + index) - v0; + + // Processing cycle by cycle + if(currentstate == 1) { + // Currrent level is HIGH + // Searching for falling transition + if(tmp <= LowLevel) { + // Falling transition found + currentstate = 0; + fallingcnt++; + fallingtime = index; // Mark down the falling edge + if(fallingcnt == 1) { + // Mark down the start of valid sample + firstfalling = index; + } + if(risingcnt != 0) { + // Accumulate high level duration + highleveltime += (fallingtime - risingtime); + } + } + } + else { + // Currrent level is LOW + // Searching for rising transition + if(tmp >= HighLevel) { + // Rising transition fount + currentstate = 1; + risingcnt++; + risingtime = index; + if(risingcnt == 1) { + // Mark down the start of valid sample + firstrising = index; + } + } + + } + index++; + } + + + if((risingcnt >= 2) || (fallingcnt >= 2)) { + // At least one cycle found + BitSet(Flags, (1 << Flag_FreqValid)); + + // Calculate frequency + if(currentstate == 1) { + // The last transition is rising. Use first rising as starting point + sum = risingtime - firstrising; + risingcnt -= 1; // Number of cycles + } + else { + // The last transition is falling. Use first falling as starting point + sum = fallingtime - firstfalling; + risingcnt = fallingcnt - 1; // Number of cycles + if(firstrising < firstfalling) { + // The first crossover is rising. Take out the first segment of high level from 'highleveltime' + highleveltime -= (firstfalling - firstrising); + } + } + + Freq = ((float)risingcnt/(float)sum) * SampleRate[GetTimebase() - TBMin]; + Cycle = 1.0/Freq; + PW = ((float)highleveltime/(float)risingcnt) / SampleRate[GetTimebase() - TBMin]; + Duty = ((float)highleveltime/(float)sum) * 100.0; // In percentage + // Select frequrency unit + FreqUnit = 0; + while(Freq >= 1000.0) { + Freq /= 1000.0; + FreqUnit++; + } + // Select cycle unit + CycleUnit = 4; + while(Cycle <= 0.01) { + Cycle *= 1000.0; + PW *= 1000.0; + CycleUnit++; + } + } + else { + BitClr(Flags, (1 << Flag_FreqValid)); + } +} + +void OnScreenDisplay(void) +{ + U16 tmp1; + + // Display measurement results + tmp1 = clMeasurement; + if(!BitTest(Flags, (1 << Flag_VoltValid))) { + tmp1 = clRed; + } + + PutsGenic(VoltageReadingx0, VoltageReadingy0, (U8 *)"Vmax:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(VoltageReadingx0 + 42, VoltageReadingy0, VoltToStr(Vmax, ReadingStr), tmp1, clBlack, &ASC8X16); + + PutsGenic(VoltageReadingx0, VoltageReadingy0 + 1 * 16, (U8 *)"Vmin:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(VoltageReadingx0 + 42, VoltageReadingy0 + 1 * 16, VoltToStr(Vmin, ReadingStr), tmp1, clBlack, &ASC8X16); + + PutsGenic(VoltageReadingx0, VoltageReadingy0 + 2 * 16, (U8 *)"Vavr:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(VoltageReadingx0 + 42, VoltageReadingy0 + 2 * 16, VoltToStr(Vavr, ReadingStr), tmp1, clBlack, &ASC8X16); + + PutsGenic(VoltageReadingx0, VoltageReadingy0 + 3 * 16, (U8 *)"Vpp:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(VoltageReadingx0 + 42, VoltageReadingy0 + 3 * 16, VoltToStr(Vpp, ReadingStr), tmp1, clBlack, &ASC8X16); + + PutsGenic(VoltageReadingx0, VoltageReadingy0 + 4 * 16, (U8 *)"Vrms:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(VoltageReadingx0 + 42, VoltageReadingy0 + 4 * 16, VoltToStr(Vrms, ReadingStr), tmp1, clBlack, &ASC8X16); + + PutsGenic(FreqReadingx0, FreqReadingy0, (U8 *)"Freq:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0, FreqReadingy0 + 1 * 16, (U8 *)"Cycl:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0, FreqReadingy0 + 2 * 16, (U8 *)"PW:", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0, FreqReadingy0 + 3 * 16, (U8 *)"Duty:", clMeasurement, clBlack, &ASC8X16); + if(BitTest(Flags, (1 << Flag_FreqValid))) { + FloatToStr(Freq, 3, 3, ReadingStr); + strcat(ReadingStr, UnitsStr[FreqUnit]); + if((tmp1 = strlen(ReadingStr)) < FreqStrLen) { + // Clear previous display + FillRect(FreqReadingx0 + 42, FreqReadingy0, FreqStrLen * 8, 16, clBlack); + } + FreqStrLen = tmp1; + PutsGenic(FreqReadingx0 + 42, FreqReadingy0, ReadingStr, clMeasurement, clBlack, &ASC8X16); + + FloatToStr(Cycle, 3, 3, ReadingStr); + strcat(ReadingStr, UnitsStr[CycleUnit]); + if((tmp1 = strlen(ReadingStr)) < CycleStrLen) { + // Clear previous display + FillRect(FreqReadingx0 + 42, FreqReadingy0 + 1 * 16, CycleStrLen * 8, 16, clBlack); + } + CycleStrLen = tmp1; + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 1 * 16, ReadingStr, clMeasurement, clBlack, &ASC8X16); + + FloatToStr(PW, 3, 3, ReadingStr); + strcat(ReadingStr, UnitsStr[CycleUnit]); + if((tmp1 = strlen(ReadingStr)) < PwStrLen) { + // Clear previous display + FillRect(FreqReadingx0 + 42, FreqReadingy0 + 2 * 16, PwStrLen * 8, 16, clBlack); + } + PwStrLen = tmp1; + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 2 * 16, ReadingStr, clMeasurement, clBlack, &ASC8X16); + + FloatToStr(Duty, 3, 1, ReadingStr); + strcat(ReadingStr, " %"); + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 3 * 16, ReadingStr, clMeasurement, clBlack, &ASC8X16); + BitClr(Flags, (1 << Flag_FreqAreaCleared)); + } + else { + if(!BitTest(Flags, (1 << Flag_FreqAreaCleared))) { + FillRect(FreqReadingx0 + 42, FreqReadingy0, 120, 70, clBlack); + BitSet(Flags, (1 << Flag_FreqAreaCleared)); + } + PutsGenic(FreqReadingx0 + 42, FreqReadingy0, (U8 *)"----", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 1 * 16, (U8 *)"----", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 2 * 16, (U8 *)"----", clMeasurement, clBlack, &ASC8X16); + PutsGenic(FreqReadingx0 + 42, FreqReadingy0 + 3 * 16, (U8 *)"----", clMeasurement, clBlack, &ASC8X16); + } + + + if(BitTest(AddOns, (1 << AO_TestSigAmpDisp))) { + // Display test signal amplitude + if(BitTest(AddOns, (1 << AO_TestSigAmp))) { + // Amp is 0.1V + PutsGenic(TestSigAmpx0, TestSigAmpy0, "T.S. Amp: 0.1V", clWhite, clBlue, &ASC8X16); + } + else { + // Amp is normal (3.3V) + PutsGenic(TestSigAmpx0, TestSigAmpy0, "T.S. Amp: 3.3V", clWhite, clBlue, &ASC8X16); + } + } + +} + +void TestSigAmpDisplay(void) +{ + // Display test signal amplitude + if(BitTest(AddOns, (1 << AO_TestSigAmp))) { + // Amp is 0.1V + PutsGenic(TestSigAmpx0, TestSigAmpy0, "T.S. Amp: 0.1V", clWhite, clBlue, &ASC8X16); + } + else { + // Amp is normal (3.3V) + PutsGenic(TestSigAmpx0, TestSigAmpy0, "T.S. Amp: 3.3V", clWhite, clBlue, &ASC8X16); + } + +} +// --------------------------------------------------------------- +// Convert voltage to string +// +U8 *VoltToStr(S16 volt, U8 *strbuf) +{ + float ftmp; + U8 tmp0; + U16 tmp1; + S8 tmp2; + + // Get current Vsen + tmp2 = GetVSen(); + + // Calculate voltage. The unit of ftmp is mV + ftmp = ((float)(volt >> 2) * (3300.0/4096.0)) * UnitRate[tmp2 - VSenMin] * 1.007; + if(ftmp >= 0) { + tmp0 = ' '; + tmp1 = (U16)ftmp; + } + else { + tmp0 = '-'; + tmp1 = (U16)(-ftmp); + } + BinToDecStr16(tmp1, strbuf + 1); + + if(tmp2 <= VS_01V) { + // Unit 'V" + *(strbuf + 5) = *(strbuf + 4); + *(strbuf + 4) = *(strbuf + 3); + *(strbuf + 3) = '.'; + *(strbuf + 6) = 'V'; + *(strbuf + 7) = 0; + + // Remove leading 0's + if(*(strbuf + 1) == '0') { + *(strbuf + 1) = tmp0; + *(strbuf + 0) = ' '; +// tmp2 = 1; + } + else { + *(strbuf + 0) = tmp0; // Sign +// tmp2 = 0; + } + } + else { + *(strbuf + 0) = ' '; + *(strbuf + 1) = *(strbuf + 2); + *(strbuf + 2) = *(strbuf + 3); + *(strbuf + 3) = *(strbuf + 4); + *(strbuf + 4) = *(strbuf + 5); + *(strbuf + 5) = 'm'; + *(strbuf + 6) = 'V'; + *(strbuf + 7) = 0; + // Remove leading 0's + tmp2 = 1; + while(tmp2 < 4) { + if(*(strbuf + tmp2) == '0') { + *(strbuf + tmp2) = ' '; + } + else { + break; + } + tmp2++; + } + tmp2--; + *(strbuf + tmp2) = tmp0; // Sign + } + + return strbuf; +} + +U8 *BinToDecStr16(U16 binary, U8 *Str) +{ + U8 tmp0; + + tmp0 = binary/10000; + *(Str + 0) = 0x30 | tmp0; + binary = binary - tmp0 * 10000; + + tmp0 = binary/1000; + *(Str + 1) = 0x30 | tmp0; + binary = binary - tmp0 * 1000; + + tmp0 = binary/100; + *(Str + 2) = 0x30 | tmp0; + binary = binary - tmp0 * 100; + + tmp0 = binary/10; + *(Str + 3) = 0x30 | tmp0; + binary = binary - tmp0 * 10; + + *(Str + 4) = 0x30 | binary; + + *(Str + 5) = 0; + + return Str; + +} + +// ------------------------------------------------------------------------ +// Convert float number 'f' to string with 'width' digits of whole and 'precision' digits of fraction +// digits. Return pointer to the string. +// Condition: f < 10^10, width < 10, presicion < 10 +U8 *FloatToStr(float f, U8 width, U8 precision, U8 *str) +{ + U32 tmp0; + U8 tmp1, tmp3, tmp4; + U8 tmpstr[24], *ptmp; + + tmp1 = 0; + if(f < 0.0) { + tmp1 = 1; // Negative + f = 0.0 - f; + } + + tmp0 = f; // Whole portion + BinToDec32(tmp0, &tmpstr[1]); + + tmp3 = 0; +// Looking for the first non-zero digit + while(tmp3 < 10) { + if(tmpstr[tmp3 + 1] != '0') { + break; + } + tmp3++; + } + DeZero(&tmpstr[tmp3 + 1], width, ' '); + if(tmp3 == 10) { + tmpstr[10] = '0'; // Whole part is zero. Keep one '0' before decimal point + tmp3 = 9; + } + + // Add '-' for negative number + if(tmp1) { + tmpstr[tmp3] = '-'; + } + else { + tmpstr[tmp3] = ' '; + } + + if(precision == 0) { + // No fraction required + tmpstr[11] = 0; + } + else { + tmpstr[11] = '.'; + f = f - (float)tmp0; // Get fraction + tmp4 = precision; + while(tmp4) { + f *= 10.0; + tmp4--; + } + tmp0 = f; // Fraction + BinToDec32(tmp0, &tmpstr[12]); + // Advance the digits of interest + tmp4 = 0; + while(tmp4 < precision) { + tmpstr[12 + tmp4] = tmpstr[12 + (10 - precision) + tmp4]; + tmp4++; + } + tmpstr[12 + tmp4] = 0; + } + + ptmp = str; + tmp4 = 0; + while((*ptmp++ = tmpstr[tmp3 + tmp4])) { + tmp4++; + } + return str; +} + +U8 *BinToDec32(U32 binary, U8 *Str) +{ + U8 tmp0; + tmp0 = 0; + while(tmp0 <= 9) { + binary = FindDec(binary, tmp0, (U8 *)Str); + tmp0++; + } + + *(Str + 10) = 0; + + return Str; + +} + +U32 FindDec(U32 bin, U8 ind, U8 *str) +{ + U8 tmp; + U32 tmp1; + + tmp1 = 1; + tmp = 9 - ind; + while(tmp) { + tmp1 *= 10; + tmp--; + } + + tmp = bin/tmp1; + *(str + ind) = 0x30 | tmp; + return (bin - tmp * tmp1); +} + +// Remove leading zeros for the first 'num' digits. Replace them with 'ch' +void DeZero(U8 *str, U8 num, U8 ch) +{ + U8 tmp; + + tmp = 0; + while(tmp < num) { + if(*str == '0') { + *str = ch; + } + else { + break; + } + str++; + } + + // Put '0' back if '.' is the first non-zero digit + if(*str == '.') { + str--; + *str = '0'; + } +} + diff --git a/Command.h b/Command.h new file mode 100644 index 0000000..dd23876 --- /dev/null +++ b/Command.h @@ -0,0 +1,205 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Command.h +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// +// +#ifndef Command_h +#define Command_h + +#include "Common.h" + +// ============== Key Analysis Definitions ===================== + +typedef struct { + // Keypad processing variables + U16 Flags; + U16 KScanBuf; + U16 KScanCode; + U16 KeyCode; + U16 KeyParam; + U16 KeyCodeBuf; + U16 KCount; // Key debounce counter + U16 KDebounceVal; // Debounce timing length (number of scans) + U16 KHCount; // Key hold counter + U16 KTimeChk; // Key time check + U16 EncState; + + } KEYPAD; + +enum KeypadFlags { + KF_DoKeyScan = 0, + KF_PressDetected = 1, + KF_HoldDetected = 2, + KF_KeyHit = 3, + + }; + +// -- Key-Event mapping +typedef struct { + U8 Keycode; + U8 Event; + }KeyEvent ; + +// -- Key code conversion +typedef struct { + U16 ScanCode; + U8 Keycode; + }KeyMap ; + +// -------------------------------------- +// Keypad +typedef struct { + U16 ScanCode; + U8 KeyCode; + U8 KeyParam; + }KeyScanCode; + +// -- Key Code Definitions +enum KeyCodes { + KC_void = 0, + KC_SW1, + KC_SW2, + KC_SW3, + KC_SW4, + KC_SW1H, + KC_SW2H, + KC_SW3H, + KC_SW4H, + KC_SW1_SW4, + KC_SW2_SW4, + KC_SW3_SW4, + KC_SW2_SW3, + KC_SW2_SW3H, + KC_ENC_CW, + KC_ENC_CCW, + KC_ENC_PB, + KC_ENC_PBH, + KC_PB_SW1, + KC_PB_SW2, + KC_PB_SW3, + KC_PB_SW4, + }; + +// Pushbutton processing parameters +#define NoKey 0xFFFF + +#define KD_val 6 // +#define KD_val1 15 // +#define KH_val 90 // +#define KR_Time 3 + +// Add-ons +enum AddOn { + AO_MeasurementOn = 0, + AO_TestSigAmp = 1, // 0 - normal (3.3V), 1 - 0.1V + AO_TestSigAmpDisp = 2, + +}; + +// Setting status +#define SettingStatus_Initialized 0xF3A5 + +#define VoltageReadingx0 205 +#define VoltageReadingy0 20 +#define FreqReadingx0 15 +#define FreqReadingy0 20 +#define TestSigAmpx0 15 +#define TestSigAmpy0 (WWindowy0 + WWindowSizey - 20) + +#define Flag_MeasurementOn 0 +#define Flag_FreqValid 1 +#define Flag_VoltValid 2 +#define Flag_FreqAreaCleared 3 + +#define Waveform_START_ADDRESS ((uint32_t)0x0800E000) +#define Parameter_START_ADDRESS ((uint32_t)0x0800E800) + +// =========================================================== +// Export variables +// =========================================================== +// +extern U16 AddOns; +extern KEYPAD Keypad; +extern S16 Vmax; +extern S16 Vmin; +extern S16 Vavr; +extern S16 Vpp; +extern S16 Vrms; +extern U8 ReadingStr[]; +extern U8 MeasurementOn; +extern float Freq; +extern float Cycle; +extern float PW; +extern float Duty; +extern U16 Flags; +extern U16 FreqUnit; +extern U16 CycleUnit; +extern U16 FreqStrLen; +extern U16 CycleStrLen; +extern U16 PwStrLen; +extern U8 *UnitsStr[8]; + +// =========================================================== +// Function Declarations +// =========================================================== +// +void AppInit(); +void LoadDefault(void); +void KeyScan(void); +void KeyConvert(KeyScanCode *KSCTab, U16 KSCode); +U8 KeyEventMap(U8 keycode, KeyEvent *kvmap); +void KeyProc(void); +void DoKeyOk(void); +void DoKeyInc(void); +void DoKeyDec(void); +void DoKeySel(void); +void DoKeyOkH(void); +void DoKeyIncH(void); +void DoKeyDecH(void); +void DoKeySelH(void); +void SelVertical(void); +void SelHorzontal(void); +void SelTrigger(void); +void VPosAlign(void); +void CenterHPos(void); +void CenterTrigLevel(void); +void LedBlink(void); +void LedBlink_Fast(void); +void TestMode(void); +void SaveWaveform(void); +void LoadWaveform(void); +void Measurements(void); +void OnScreenDisplay(void); +void TestSigAmpDisplay(void); +U8 *VoltToStr(S16 volt, U8 *strbuf); +U8 *BinToDecStr16(U16 binary, U8 *Str); +U8 *BinToDec32(U32 binary, U8 *Str); +U32 FindDec(U32 bin, U8 ind, U8 *str); +void DeZero(U8 *str, U8 num, U8 ch); +U8 *FloatToStr(float f, U8 width, U8 precision, U8 *str); + + +#endif + diff --git a/Common.c b/Common.c new file mode 100644 index 0000000..fa3df24 --- /dev/null +++ b/Common.c @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Common.c +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#include "Common.h" + +void Delay(volatile U16 count) +{ + while(count) { + count--; + } +} + +// ------------------------------------------------------------------------- +// Convert binary to hexical digit string. 'size' is in bytes. +// +U8* BinToHexStr(U32 bin, U8 *str, U8 size) +{ + U8 tmp0; + + size = 2 * size + 2; + *(str + size) = 0; // end of string + size--; + while(size >= 2) { + tmp0 = 0x0000000F & bin; + if(tmp0 <= 9) { + tmp0 |= 0x30; + } + else { + tmp0 += 0x37; + } + *(str + size) = tmp0; + bin >>= 4; + size--; + } + *(str + size--) = 'x'; + *(str + size) = '0'; + return str; +} + diff --git a/Common.h b/Common.h new file mode 100644 index 0000000..c46f700 --- /dev/null +++ b/Common.h @@ -0,0 +1,71 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Common.h +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// + +#ifndef Common_h + +#define Common_h + +typedef unsigned char U8; +typedef signed char S8; +typedef unsigned short int U16; +typedef signed short int S16; +typedef unsigned long U32; +typedef signed long S32; + +typedef void (*FuncPointer)(U8); +typedef void (*CmdFuncPointer)(void); +typedef void (*StateAction)(void); + +// -- Control debug code generation +//#define _Debug_ + +// ============= Macro definitions =========================== + +#define BitSet(word, bit_mask) ((word) |= (bit_mask)) +#define BitClr(word, bit_mask) ((word) &= ~(bit_mask)) +#define BitTest(word, bit_mask) ((word) & (bit_mask)) +#define BitAnd(word, bit_mask) ((word) &= (bit_mask)) +#define BitOr(word, bit_mask) ((word) |= (bit_mask)) +#define BitXor(word, bit_mask) ((word) ^= (bit_mask)) + +#define Port_BitSet(port, bit_mask) (port->BSRR = bit_mask) +#define Port_BitClr(port, bit_mask) (port->BRR = bit_mask) + +#define SetToLow(port, bit_mask) (port->BRR = bit_mask) +#define SetToHigh(port, bit_mask) (port->BSRR = bit_mask) + + +// =========================================================== +// Function Prototype Declarations +// =========================================================== +// +void Delay(U16 count); +U8* BinToHexStr(U32 bin, U8 *str, U8 size); + +#endif // Common_h + diff --git a/Eeprom.c b/Eeprom.c new file mode 100644 index 0000000..f17a5c4 --- /dev/null +++ b/Eeprom.c @@ -0,0 +1,644 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/src/eeprom.c + * @author MCD Application Team + * @version V3.1.0 + * @date 07/27/2009 + * @brief This file provides all the EEPROM emulation firmware functions. + ****************************************************************************** + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2009 STMicroelectronics

+ */ +/** @addtogroup EEPROM_Emulation + * @{ + */ + +/* Includes ------------------------------------------------------------------*/ +#include "eeprom.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +FLASH_Status FlashStatus; + + +// Virtual address defined by the user: 0xFFFF value is prohibited +uint16_t VirtAddVarTab[NumbOfVar] = { + Addr_TimeBase, + Addr_HPos, + Addr_Vsen, + Addr_Cpl, + Addr_Vpos, + Addr_VPosOfs, + Addr_TrigMode, + Addr_TrigEdge, + Addr_TrigLvl, + Addr_TrigPos, + Addr_RecLen, + Addr_AddOns, + Addr_SettingStatus, + Addr_TftController, + Addr_VPosOfs00, + Addr_VPosOfs01, + Addr_VPosOfs02, + Addr_VPosOfs03, + Addr_VPosOfs04, + Addr_VPosOfs05, + Addr_VPosOfs06, + Addr_VPosOfs07, + Addr_VPosOfs08, + Addr_VPosOfs09, + Addr_VPosOfs10, + Addr_VPosOfs11, + + }; + +/* Global variable used to store variable value in read sequence */ +uint16_t DataVar = 0; + +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +static FLASH_Status EE_Format(void); +static uint16_t EE_FindValidPage(uint8_t Operation); +static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data); +static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data); + +/** + * @brief Restore the pages to a known good state in case of page's status + * corruption after a power loss. + * @param None. + * @retval - Flash error code: on write Flash error + * - FLASH_COMPLETE: on success + */ +uint16_t EE_Init(void) +{ + uint16_t PageStatus0 = 6, PageStatus1 = 6; + uint16_t VarIdx = 0; + uint16_t EepromStatus = 0, ReadStatus = 0; + int16_t x = -1; + uint16_t FlashStatus; + + /* Get Page0 status */ + PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); + /* Get Page1 status */ + PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS); + + /* Check for invalid header states and repair if necessary */ + switch (PageStatus0) + { + case ERASED: + if (PageStatus1 == VALID_PAGE) /* Page0 erased, Page1 valid */ + { + /* Erase Page0 */ + FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else if (PageStatus1 == RECEIVE_DATA) /* Page0 erased, Page1 receive */ + { + /* Erase Page0 */ + FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + /* Mark Page1 as valid */ + FlashStatus = FLASH_ProgramHalfWord(PAGE1_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + FlashStatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + break; + + case RECEIVE_DATA: + if (PageStatus1 == VALID_PAGE) /* Page0 receive, Page1 valid */ + { + /* Transfer data from Page1 to Page0 */ + for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++) + { + if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx]) + { + x = VarIdx; + } + if (VarIdx != x) + { + /* Read the last variables' updates */ + ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (ReadStatus != 0x1) + { + /* Transfer the variable to the Page0 */ + EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (EepromStatus != FLASH_COMPLETE) + { + return EepromStatus; + } + } + } + } + /* Mark Page0 as valid */ + FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + /* Erase Page1 */ + FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else if (PageStatus1 == ERASED) /* Page0 receive, Page1 erased */ + { + /* Erase Page1 */ + FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + /* Mark Page0 as valid */ + FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else /* Invalid state -> format eeprom */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + FlashStatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + break; + + case VALID_PAGE: + if (PageStatus1 == VALID_PAGE) /* Invalid state -> format eeprom */ + { + /* Erase both Page0 and Page1 and set Page0 as valid page */ + FlashStatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else if (PageStatus1 == ERASED) /* Page0 valid, Page1 erased */ + { + /* Erase Page1 */ + FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + else /* Page0 valid, Page1 receive */ + { + /* Transfer data from Page0 to Page1 */ + for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++) + { + if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx]) + { + x = VarIdx; + } + if (VarIdx != x) + { + /* Read the last variables' updates */ + ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (ReadStatus != 0x1) + { + /* Transfer the variable to the Page1 */ + EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (EepromStatus != FLASH_COMPLETE) + { + return EepromStatus; + } + } + } + } + /* Mark Page1 as valid */ + FlashStatus = FLASH_ProgramHalfWord(PAGE1_BASE_ADDRESS, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + /* Erase Page0 */ + FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + } + break; + + default: /* Any other state -> format eeprom */ + /* Erase both Page0 and Page1 and set Page0 as valid page */ + FlashStatus = EE_Format(); + /* If erase/program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + break; + } + + return FLASH_COMPLETE; +} + +/** + * @brief Returns the last stored variable data, if found, which correspond to + * the passed virtual address + * @param VirtAddress: Variable virtual address + * @param Data: Global variable contains the read variable value + * @retval Success or error status: + * - 0: if variable was found + * - 1: if the variable was not found + * - NO_VALID_PAGE: if no valid page was found. + */ +uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data) +{ + uint16_t ValidPage = PAGE0; + uint16_t AddressValue = 0x5555, ReadStatus = 1; + uint32_t Address = 0x08010000, PageStartAddress = 0x08010000; + + /* Get active Page for read operation */ + ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE); + + /* Check if there is no valid page */ + if (ValidPage == NO_VALID_PAGE) + { + return NO_VALID_PAGE; + } + + /* Get the valid Page start Address */ + PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE)); + + /* Get the valid Page end Address */ + Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE)); + + /* Check each active page address starting from end */ + while (Address > (PageStartAddress + 2)) + { + /* Get the current location content to be compared with virtual address */ + AddressValue = (*(__IO uint16_t*)Address); + + /* Compare the read address with the virtual address */ + if (AddressValue == VirtAddress) + { + /* Get content of Address-2 which is variable value */ + *Data = (*(__IO uint16_t*)(Address - 2)); + + /* In case variable value is read, reset ReadStatus flag */ + ReadStatus = 0; + + break; + } + else + { + /* Next address location */ + Address = Address - 4; + } + } + + /* Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) */ + return ReadStatus; +} + +/** + * @brief Writes/upadtes variable data in EEPROM. + * @param VirtAddress: Variable virtual address + * @param Data: 16 bit data to be written + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data) +{ + uint16_t Status = 0; + + /* Write the variable virtual address and value in the EEPROM */ + Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data); + + /* In case the EEPROM active page is full */ + if (Status == PAGE_FULL) + { + /* Perform Page transfer */ + Status = EE_PageTransfer(VirtAddress, Data); + } + + /* Return last operation status */ + return Status; +} + +/** + * @brief Erases PAGE0 and PAGE1 and writes VALID_PAGE header to PAGE0 + * @param None + * @retval Status of the last operation (Flash write or erase) done during + * EEPROM formating + */ +static FLASH_Status EE_Format(void) +{ + FLASH_Status FlashStatus = FLASH_COMPLETE; + + /* Erase Page0 */ + FlashStatus = FLASH_ErasePage(PAGE0_BASE_ADDRESS); + + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + + /* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */ + FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE); + + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + + /* Erase Page1 */ + FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS); + + /* Return Page1 erase operation status */ + return FlashStatus; +} + +/** + * @brief Find valid Page for write or read operation + * @param Operation: operation to achieve on the valid page. + * This parameter can be one of the following values: + * @arg READ_FROM_VALID_PAGE: read operation from valid page + * @arg WRITE_IN_VALID_PAGE: write operation from valid page + * @retval Valid page number (PAGE0 or PAGE1) or NO_VALID_PAGE in case + * of no valid page was found + */ +static uint16_t EE_FindValidPage(uint8_t Operation) +{ + uint16_t PageStatus0 = 6, PageStatus1 = 6; + + /* Get Page0 actual status */ + PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); + + /* Get Page1 actual status */ + PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS); + + /* Write or read operation */ + switch (Operation) + { + case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */ + if (PageStatus1 == VALID_PAGE) + { + /* Page0 receiving data */ + if (PageStatus0 == RECEIVE_DATA) + { + return PAGE0; /* Page0 valid */ + } + else + { + return PAGE1; /* Page1 valid */ + } + } + else if (PageStatus0 == VALID_PAGE) + { + /* Page1 receiving data */ + if (PageStatus1 == RECEIVE_DATA) + { + return PAGE1; /* Page1 valid */ + } + else + { + return PAGE0; /* Page0 valid */ + } + } + else + { + return NO_VALID_PAGE; /* No valid Page */ + } + + case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */ + if (PageStatus0 == VALID_PAGE) + { + return PAGE0; /* Page0 valid */ + } + else if (PageStatus1 == VALID_PAGE) + { + return PAGE1; /* Page1 valid */ + } + else + { + return NO_VALID_PAGE ; /* No valid Page */ + } + + default: + return PAGE0; /* Page0 valid */ + } +} + +/** + * @brief Verify if active page is full and Writes variable in EEPROM. + * @param VirtAddress: 16 bit virtual address of the variable + * @param Data: 16 bit data to be written as variable value + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data) +{ + FLASH_Status FlashStatus = FLASH_COMPLETE; + uint16_t ValidPage = PAGE0; + uint32_t Address = 0x08010000, PageEndAddress = 0x080107FF; + + /* Get valid Page for write operation */ + ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE); + + /* Check if there is no valid page */ + if (ValidPage == NO_VALID_PAGE) + { + return NO_VALID_PAGE; + } + + /* Get the valid Page start Address */ + Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE)); + + /* Get the valid Page end Address */ + PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE)); + + /* Check each active page address starting from begining */ + while (Address < PageEndAddress) + { + /* Verify if Address and Address+2 contents are 0xFFFFFFFF */ + if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF) + { + /* Set variable data */ + FlashStatus = FLASH_ProgramHalfWord(Address, Data); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + /* Set variable virtual address */ + FlashStatus = FLASH_ProgramHalfWord(Address + 2, VirtAddress); + /* Return program operation status */ + return FlashStatus; + } + else + { + /* Next address location */ + Address = Address + 4; + } + } + + /* Return PAGE_FULL in case the valid page is full */ + return PAGE_FULL; +} + +/** + * @brief Transfers last updated variables data from the full Page to + * an empty one. + * @param VirtAddress: 16 bit virtual address of the variable + * @param Data: 16 bit data to be written as variable value + * @retval Success or error status: + * - FLASH_COMPLETE: on success + * - PAGE_FULL: if valid page is full + * - NO_VALID_PAGE: if no valid page was found + * - Flash error code: on write Flash error + */ +static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) +{ + FLASH_Status FlashStatus = FLASH_COMPLETE; + uint32_t NewPageAddress = 0x080103FF, OldPageAddress = 0x08010000; + uint16_t ValidPage = PAGE0, VarIdx = 0; + uint16_t EepromStatus = 0, ReadStatus = 0; + + /* Get active Page for read operation */ + ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE); + + if (ValidPage == PAGE1) /* Page1 valid */ + { + /* New page address where variable will be moved to */ + NewPageAddress = PAGE0_BASE_ADDRESS; + + /* Old page address where variable will be taken from */ + OldPageAddress = PAGE1_BASE_ADDRESS; + } + else if (ValidPage == PAGE0) /* Page0 valid */ + { + /* New page address where variable will be moved to */ + NewPageAddress = PAGE1_BASE_ADDRESS; + + /* Old page address where variable will be taken from */ + OldPageAddress = PAGE0_BASE_ADDRESS; + } + else + { + return NO_VALID_PAGE; /* No valid Page */ + } + + /* Set the new Page status to RECEIVE_DATA status */ + FlashStatus = FLASH_ProgramHalfWord(NewPageAddress, RECEIVE_DATA); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + + /* Write the variable passed as parameter in the new active page */ + EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data); + /* If program operation was failed, a Flash error code is returned */ + if (EepromStatus != FLASH_COMPLETE) + { + return EepromStatus; + } + + /* Transfer process: transfer variables from old to the new active page */ + for (VarIdx = 0; VarIdx < NumbOfVar; VarIdx++) + { + if (VirtAddVarTab[VarIdx] != VirtAddress) /* Check each variable except the one passed as parameter */ + { + /* Read the other last variable updates */ + ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar); + /* In case variable corresponding to the virtual address was found */ + if (ReadStatus != 0x1) + { + /* Transfer the variable to the new active page */ + EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar); + /* If program operation was failed, a Flash error code is returned */ + if (EepromStatus != FLASH_COMPLETE) + { + return EepromStatus; + } + } + } + } + + /* Erase the old Page: Set old Page status to ERASED status */ + FlashStatus = FLASH_ErasePage(OldPageAddress); + /* If erase operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + + /* Set new Page status to VALID_PAGE status */ + FlashStatus = FLASH_ProgramHalfWord(NewPageAddress, VALID_PAGE); + /* If program operation was failed, a Flash error code is returned */ + if (FlashStatus != FLASH_COMPLETE) + { + return FlashStatus; + } + + /* Return last operation flash status */ + return FlashStatus; +} + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/Eeprom.h b/Eeprom.h new file mode 100644 index 0000000..38945ef --- /dev/null +++ b/Eeprom.h @@ -0,0 +1,113 @@ +/** + ****************************************************************************** + * @file EEPROM_Emulation/inc/eeprom.h + * @author MCD Application Team + * @version V3.1.0 + * @date 07/27/2009 + * @brief This file contains all the functions prototypes for the EEPROM + * emulation firmware library. + ****************************************************************************** + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2009 STMicroelectronics

+ */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __EEPROM_H +#define __EEPROM_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/* Exported constants --------------------------------------------------------*/ +/* Define the STM32F10Xxx Flash page size depending on the used STM32 device */ +#if defined (STM32F10X_LD) || defined (STM32F10X_MD) + #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */ +#elif defined (STM32F10X_HD) || defined (STM32F10X_CL) + #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */ +#endif + +/* EEPROM start address in Flash */ +#define EEPROM_START_ADDRESS ((uint32_t)0x0800F000) /* EEPROM emulation start address: + after 64KByte of used Flash memory */ + +/* Pages 0 and 1 base and end addresses */ +#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000)) +#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) + +#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE)) +#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) + +/* Used Flash pages for EEPROM emulation */ +#define PAGE0 ((uint16_t)0x0000) +#define PAGE1 ((uint16_t)0x0001) + +/* No valid page define */ +#define NO_VALID_PAGE ((uint16_t)0x00AB) + +/* Page status definitions */ +#define ERASED ((uint16_t)0xFFFF) /* PAGE is empty */ +#define RECEIVE_DATA ((uint16_t)0xEEEE) /* PAGE is marked to receive data */ +#define VALID_PAGE ((uint16_t)0x0000) /* PAGE containing valid data */ + +/* Valid pages in read and write defines */ +#define READ_FROM_VALID_PAGE ((uint8_t)0x00) +#define WRITE_IN_VALID_PAGE ((uint8_t)0x01) + +/* Page full define */ +#define PAGE_FULL ((uint8_t)0x80) + +/* Variables' number */ +#define NumbOfVar ((uint8_t)27) + +/* Virtual address defined by the user: 0xFFFF value is prohibited */ +extern uint16_t VirtAddVarTab[NumbOfVar]; + +// Define virtual EEPROM addresses to be used here +enum { + Addr_TimeBase = 0, + Addr_HPos, + Addr_Vsen, + Addr_Cpl, + Addr_Vpos, + Addr_VPosOfs, + Addr_TrigMode, + Addr_TrigEdge, + Addr_TrigLvl, + Addr_TrigPos, + Addr_RecLen, + Addr_AddOns, + Addr_SettingStatus, + Addr_TftController, + Addr_VPosOfs00, // for 20V/div + Addr_VPosOfs01, // for 10V/div + Addr_VPosOfs02, // for 5V/div + Addr_VPosOfs03, // for 2V/div + Addr_VPosOfs04, // for 1V/div + Addr_VPosOfs05, // for 0.5V/div + Addr_VPosOfs06, // for 0.2V/div + Addr_VPosOfs07, // for 0.1V/div + Addr_VPosOfs08, // for 50mV/div + Addr_VPosOfs09, // for 20mV/div + Addr_VPosOfs10, // for 10mV/div + Addr_VPosOfs11, // for 5mV/div + + }; + +/* Exported types ------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +uint16_t EE_Init(void); +uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data); +uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data); + +#endif /* __EEPROM_H */ + +/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3edda7c --- /dev/null +++ b/Makefile @@ -0,0 +1,617 @@ +# +# WinARM template makefile +# +# +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make program = Upload load-image to the device +# +# make filename.s = Just compile filename.c into the assembler code only +# +# make filename.o = Create object filename.o from filename.c (using CFLAGS) +# +# To rebuild project do "make clean" then "make all". +# + +# This should work with just CS G++ lite installed (Win32 cmd as shell, cs-make, cs-rm) +# Tested with: +# - CS G++ 2009-Q1 (cs-make 3.81, cs-rm, cmd.exe), no MinGW or Cygwin tools in the $PATH +# - Cygwin (make 3.81, rm, bash 3.2.39) +# - MSYS/MinGW tools in $(PATH) (WinAVR\utils\bin) + + +# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe) +#TCHAIN_PREFIX = arm-eabi- +#TCHAIN_PREFIX = arm-elf- +TCHAIN_PREFIX = arm-none-eabi- +#REMOVE_CMD=rm +REMOVE_CMD=cs-rm + +#FLASH_TOOL = OPENOCD +#FLASH_TOOL = LPC21ISP +#FLASH_TOOL = UVISION + +# YES enables -mthumb option to flags for source-files listed +# in SRC and CPPSRC and -mthumb-interwork option for all source +USE_THUMB_MODE = YES +#USE_THUMB_MODE = NO + +# MCU name, submodel and board +# - MCU used for compiler-option (-mcpu) +# - SUBMDL used for linker-script name (-T) and passed as define +# - BOARD just passed as define (optional) +MCU = cortex-m3 +CHIP = STM32F10x_64k_20k +BOARD = JYE109-15000-00D +F_XTAL = 8000000 +SYSCLOCK_CL = SYSCLK_FREQ_72MHz=72000000 + +# *** This example only supports "FLASH_RUN" *** +# RUN_MODE is passed as define and used for the linker-script filename, +# the user has to implement the necessary operations for +# the used mode(s) (i.e. no copy of .data, remapping) +# Create FLASH-Image +RUN_MODE=FLASH_RUN +# Create RAM-Image +#RUN_MODE=RAM_RUN + +# Exception-vectors placement option is just passed as define, +# the user has to implement the necessary operations (i.e. remapping) +# Exception vectors in FLASH: +ifeq ($(RUN_MODE),RAM_RUN) +VECTOR_TABLE_LOCATION=VECT_TAB_RAM +else +VECTOR_TABLE_LOCATION=VECT_TAB_FLASH +endif + +#VECTOR_TABLE_LOCATION=VECT_TAB_FLASH +# Exception vectors in RAM: +#VECTOR_TABLE_LOCATION=VECT_TAB_RAM + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR = $(RUN_MODE) + +# Target file name (without extension). +TARGET = 113-15011-060 + +# Pathes to libraries +APPLIBDIR = ./Libraries +STMLIBDIR = $(APPLIBDIR) +STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver +STMSPDSRCDIR = $(STMSPDDIR)/src +STMSPDINCDIR = $(STMSPDDIR)/inc +CMSISDIR = $(STMLIBDIR)/CMSIS/CM3/CoreSupport + +# List C source files here. (C dependencies are automatically generated.) +# use file-extension c for "c-only"-files +## Demo-Application: +SRC = 113-15011.c Board.c Common.c Screen.c Command.c stm32f10x_it.c Eeprom.c + +## compiler-specific sources +#SRC += startup_stm32f10x_md_mthomas.c +## CMSIS for STM32 +SRC += $(CMSISDIR)/core_cm3.c +SRC += $(CMSISDIR)/system_stm32f10x.c +## used parts of the STM-Library +SRC += $(STMSPDSRCDIR)/misc.c +SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c +SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c +SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c +SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c +SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c +#SRC += $(STMSPDSRCDIR)/stm32f10x_fsmc.c + +# List C source files here which must be compiled in ARM-Mode (no -mthumb). +# use file-extension c for "c-only"-files +SRCARM = + +# List C++ source files here. +# use file-extension .cpp for C++-files (not .C) +#CPPSRC = main.cpp myclasses.cpp +#CPPSRC += mini_cpp.cpp + +# List C++ source files here which must be compiled in ARM-Mode. +# use file-extension .cpp for C++-files (not .C) +#CPPSRCARM = $(TARGET).cpp + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = startup_stm32f10x_md.S + +# List Assembler source files here which must be assembled in ARM-Mode.. +ASRCARM = + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS = $(STMSPDINCDIR) $(CMSISDIR) $(FATSDDIR) $(MININIDIR) $(STMEEEMULINCDIR) +EXTRAINCDIRS += $(APPLIBDIR) $(SWIMSRCDIR) +EXTRAINCDIRS += C:/Engineering/SourceryCodeBenchLite/arm-none-eabi/include +EXTRAINCDIRS += ./Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x +# Extra libraries +# Each library-name must be seperated by a space. +# i.e. to link with libxyz.a, libabc.a and libefsl.a: +# EXTRA_LIBS = xyz abc efsl +# for newlib-lpc (file: libnewlibc-lpc.a): +# EXTRA_LIBS = newlib-lpc +EXTRA_LIBS = dso150 + +# Path to Linker-Scripts +LINKERSCRIPTPATH = . +LINKERSCRIPTINC = . + +# List any extra directories to look for library files here. +# Also add directories where the linker should search for +# includes from linker-script to the list +# Each directory must be seperated by a space. +EXTRA_LIBDIRS = $(LINKERSCRIPTINC) + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +#OPT = s +OPT = 2 +#OPT = 3 +#OPT = 0 + +# Output format. (can be ihex or binary or both) +# binary to create a load-image in raw-binary format i.e. for SAM-BA, +# ihex to create a load-image in Intel hex format i.e. for lpc21isp +#LOADFORMAT = ihex +#LOADFORMAT = binary +LOADFORMAT = both + +# Using the Atmel AT91_lib produces warnings with +# the default warning-levels. +# yes - disable these warnings +# no - keep default settings +#AT91LIBNOWARN = yes +AT91LIBNOWARN = no + +# Debugging format. +#DEBUG = stabs +#DEBUG = dwarf-2 +DEBUG = gdb + +# Place project-specific -D (define) and/or +# -U options for C here. +CDEFS = -DSTM32F10X_MD +CDEFS += -DHSE_VALUE=$(F_XTAL)UL +CDEFS += -D$(SYSCLOCK_CL) +CDEFS += -DUSE_STDPERIPH_DRIVER +CDEFS += -DUSE_$(BOARD) +CDEFS += -DSTM32_SD_USE_DMA +CDEFS += -DSTARTUP_DELAY +# enable modifications in STM's libraries +CDEFS += -DMOD_MTHOMAS_STMLIB +# enable parameter-checking in STM's library +CDEFS += -DUSE_FULL_ASSERT + +# Place project-specific -D and/or -U options for +# Assembler with preprocessor here. +#ADEFS = -DUSE_IRQ_ASM_WRAPPER +ADEFS = -D__ASSEMBLY__ + +# Compiler flag to set the C Standard level. +# c89 - "ANSI" C +# gnu89 - c89 plus GCC extensions +# c99 - ISO C99 standard (not yet fully implemented) +# gnu99 - c99 plus GCC extensions +CSTANDARD = -std=gnu99 + +#----- + +ifdef VECTOR_TABLE_LOCATION +CDEFS += -D$(VECTOR_TABLE_LOCATION) +ADEFS += -D$(VECTOR_TABLE_LOCATION) +endif + +CDEFS += -D$(RUN_MODE) -D$(CHIP) +ADEFS += -D$(RUN_MODE) -D$(CHIP) + + +# Compiler flags. + +ifeq ($(USE_THUMB_MODE),YES) +THUMB = -mthumb +THUMB_IW = -mthumb-interwork +else +THUMB = +THUMB_IW = +endif + +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +# +# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +CFLAGS = -g$(DEBUG) +CFLAGS += -O$(OPT) +CFLAGS += -mcpu=$(MCU) $(THUMB_IW) +CFLAGS += $(CDEFS) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +# when using ".ramfunc"s without longcall: +CFLAGS += -mlong-calls +# -mapcs-frame is important if gcc's interrupt attributes are used +# (at least from my eabi tests), not needed if assembler-wrapper is used +#CFLAGS += -mapcs-frame +#CFLAGS += -fomit-frame-pointer +CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -fpromote-loop-indices +CFLAGS += -Wall -Wextra +CFLAGS += -Wimplicit -Wcast-align -Wpointer-arith +CFLAGS += -Wredundant-decls -Wshadow -Wcast-qual -Wcast-align +#CFLAGS += -pedantic +CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) +# Compiler flags to generate dependency files: +CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d + +# flags only for C +CONLYFLAGS += -Wnested-externs +CONLYFLAGS += $(CSTANDARD) + +# flags only for C++ (arm-*-g++) +CPPFLAGS = -fno-rtti -fno-exceptions +CPPFLAGS = + +# Assembler flags. +# -Wa,...: tell GCC to pass this to the assembler. +# -ahlns: create listing +# -g$(DEBUG): have the assembler create line number information +ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp +ASFLAGS += $(ADEFS) +ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) +ASFLAGS += -Wa,-g$(DEBUG) +ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) + +MATH_LIB = -lm + +# Link with the GNU C++ stdlib. +CPLUSPLUS_LIB = -lstdc++ +#CPLUSPLUS_LIB += -lsupc++ + +# Linker flags. +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections +#not in CPP +#LDFLAGS += -nostartfiles +LDFLAGS += -lc +LDFLAGS += $(MATH_LIB) +LDFLAGS += -lc -lgcc +LDFLAGS += $(CPLUSPLUS_LIB) +LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) +LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) + +#LDFLAGS += -u TIM1_CC_IRQHandler -u ADC1_2_IRQHandler -u DMA1_Channel1_IRQHandler + +# Set linker-script name depending on selected run-mode and submodel name +ifeq ($(RUN_MODE),RAM_RUN) +LDFLAGS +=-T$(LINKERSCRIPTPATH)/$(CHIP)_ram.ld +##LDFLAGS +=-T$(LINKERSCRIPTPATH)/sram.lds +else +LDFLAGS +=-T$(LINKERSCRIPTPATH)/$(CHIP)_flash.ld +#LDFLAGS +=-T$(LINKERSCRIPTPATH)/stm32_flash.ld +#LDFLAGS +=-T$(LINKERSCRIPTPATH)/stm32f10x_flash_offset_1.ld +##LDFLAGS +=-T$(LINKERSCRIPTPATH)/flash.lds +endif + +# --------------------------------------------------------------------------- +# Options for OpenOCD flash-programming +# see openocd.pdf/openocd.texi for further information +# +OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf +# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd +OOCD_EXE=./OpenOCD/bin/openocd +# debug level +OOCD_CL=-d0 +#OOCD_CL=-d3 +# interface and board/target settings (using the OOCD target-library here) +## OOCD_CL+=-f interface/jtagkey2.cfg -f target/stm32.cfg +OOCD_CL+=-f interface/jtagkey.cfg -f target/stm32.cfg +# initialize +OOCD_CL+=-c init +# enable "fast mode" - can be disabled for tests +OOCD_CL+=-c "fast enable" +# show the targets +OOCD_CL+=-c targets +# commands to prepare flash-write +OOCD_CL+= -c "reset halt" +# increase JTAG frequency a little bit - can be disabled for tests +OOCD_CL+= -c "jtag_khz 1200" +# flash-write and -verify +OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE)" -c "verify_image $(OOCD_LOADFILE)" +# reset target +OOCD_CL+=-c "reset run" +# terminate OOCD after programming +OOCD_CL+=-c shutdown +# --------------------------------------------------------------------------- + +# Define programs and commands. +CC = $(TCHAIN_PREFIX)gcc +CPP = $(TCHAIN_PREFIX)g++ +AR = $(TCHAIN_PREFIX)ar +OBJCOPY = $(TCHAIN_PREFIX)objcopy +OBJDUMP = $(TCHAIN_PREFIX)objdump +SIZE = $(TCHAIN_PREFIX)size +NM = $(TCHAIN_PREFIX)nm +REMOVE = $(REMOVE_CMD) -f +SHELL = sh +###COPY = cp +ifneq ($(or $(COMSPEC), $(ComSpec)),) +$(info COMSPEC detected $(COMSPEC) $(ComSpec)) +ifeq ($(findstring cygdrive,$(shell env)),) +SHELL:=$(or $(COMSPEC),$(ComSpec)) +SHELL_IS_WIN32=1 +else +$(info cygwin detected) +endif +endif +$(info SHELL is $(SHELL)) + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin, mode: $(RUN_MODE) -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after build: +MSG_LOAD_FILE = Creating load file: +MSG_EXTENDED_LISTING = Creating Extended Listing/Disassembly: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = ---- Linking : +MSG_COMPILING = ---- Compiling C : +MSG_COMPILING_ARM = ---- Compiling C ARM-only: +MSG_COMPILINGCPP = ---- Compiling C++ : +MSG_COMPILINGCPP_ARM = ---- Compiling C++ ARM-only: +MSG_ASSEMBLING = ---- Assembling: +MSG_ASSEMBLING_ARM = ---- Assembling ARM-only: +MSG_CLEANING = Cleaning project: +MSG_FORMATERROR = Can not handle output-format +MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now. +MSG_ASMFROMC = "Creating asm-File from C-Source:" +MSG_ASMFROMC_ARM = "Creating asm-File from C-Source (ARM-only):" + +# List of all source files. +ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) +# List of all source files without directory and file-extension. +ALLSRCBASE = $(notdir $(basename $(ALLSRC))) + +# Define all object files. +ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) + +# Define all listing files (used for make clean). +LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) +# Define all depedency-files (used for make clean). +DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) + +# Default target. +#all: begin gccversion sizebefore build sizeafter finished end +all: begin createdirs gccversion build sizeafter finished end + +elf: $(OUTDIR)/$(TARGET).elf +lss: $(OUTDIR)/$(TARGET).lss +sym: $(OUTDIR)/$(TARGET).sym +hex: $(OUTDIR)/$(TARGET).hex +bin: $(OUTDIR)/$(TARGET).bin + + +ifeq ($(LOADFORMAT),ihex) +build: elf hex lss sym +else +ifeq ($(LOADFORMAT),binary) +build: elf bin lss sym +else +ifeq ($(LOADFORMAT),both) +build: elf hex bin lss sym +else +$(error "$(MSG_FORMATERROR) $(FORMAT)") +endif +endif +endif + +# Create output directories. +ifdef SHELL_IS_WIN32 +createdirs: + -@md $(OUTDIR) >NUL 2>&1 || echo "" >NUL + -@md $(OUTDIR)\dep >NUL 2>&1 || echo "" >NUL +else +createdirs: + -@mkdir $(OUTDIR) 2>/dev/null || echo "" >/dev/null + -@mkdir $(OUTDIR)/dep 2>/dev/null || echo "" >/dev/null +endif + +# Eye candy. +begin: + @echo $(MSG_BEGIN) + +finished: +## @echo $(MSG_ERRORS_NONE) + +end: + @echo $(MSG_END) + +# Display sizes of sections. +ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf +##ELFSIZE = $(SIZE) --format=Berkeley --common $(OUTDIR)/$(TARGET).elf +sizebefore: +# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi + +sizeafter: +# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi + @echo $(MSG_SIZE_AFTER) + $(ELFSIZE) + +# Display compiler version information. +gccversion : + @$(CC) --version +# @echo $(ALLOBJ) + +# Program the device. +ifeq ($(FLASH_TOOL),UVISION) +# Program the device with Keil's uVision (needs configured uVision-workspace). +program: $(OUTDIR)/$(TARGET).hex + @echo "Programming with uVision" + C:\Keil\uv3\Uv3.exe -f uvisionflash.Uv2 -ouvisionflash.txt +else +ifeq ($(FLASH_TOOL),OPENOCD) +# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". +program: $(OUTDIR)/$(TARGET).elf + @echo "Programming with OPENOCD" +ifdef SHELL_IS_WIN32 + $(subst /,\,$(OOCD_EXE)) $(OOCD_CL) +else + $(OOCD_EXE) $(OOCD_CL) +endif +else +# Program the device using lpc21isp (for NXP2k and ADuC UART bootloader) +program: $(OUTDIR)/$(TARGET).hex + @echo $(MSG_LPC21_RESETREMINDER) + -$(LPC21ISP) $(LPC21ISP_OPTIONS) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL) +endif +endif + +# Create final output file (.hex) from ELF output file. +%.hex: %.elf + @echo $(MSG_LOAD_FILE) $@ + $(OBJCOPY) -O ihex $< $@ + +# Create final output file (.bin) from ELF output file. +%.bin: %.elf + @echo $(MSG_LOAD_FILE) $@ + $(OBJCOPY) -O binary $< $@ + +# Create extended listing file/disassambly from ELF output file. +# using objdump testing: option -C +%.lss: %.elf + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -C -r $< > $@ +# $(OBJDUMP) -x -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(ALLOBJ) +%.elf: $(ALLOBJ) + @echo $(MSG_LINKING) $@ +# use $(CC) for C-only projects or $(CPP) for C++-projects: +ifeq "$(strip $(CPPSRC)$(CPPARM))" "" + $(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ -nostartfiles $(LDFLAGS) +else + $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) +endif + + +# Assemble: create object files from assembler source files. +define ASSEMBLE_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo "hallo" + @echo $(MSG_ASSEMBLING) $$< to $$@ + $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@ +endef +$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) + +# Assemble: create object files from assembler source files. ARM-only +define ASSEMBLE_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo $(MSG_ASSEMBLING_ARM) $$< to $$@ + $(CC) -c $$(ASFLAGS) $$< -o $$@ +endef +$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) + + +# Compile: create object files from C source files. +define COMPILE_C_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo $(MSG_COMPILING) $$< to $$@ + $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ +endef +$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) + +# Compile: create object files from C source files. ARM-only +define COMPILE_C_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo $(MSG_COMPILING_ARM) $$< to $$@ + $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ +endef +$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) + + +# Compile: create object files from C++ source files. +define COMPILE_CPP_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo $(MSG_COMPILINGCPP) $$< to $$@ + $(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ +endef +$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) + +# Compile: create object files from C++ source files. ARM-only +define COMPILE_CPP_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) + @echo $(MSG_COMPILINGCPP_ARM) $$< to $$@ + $(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ +endef +$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) + + +# Compile: create assembler files from C source files. ARM/Thumb +$(SRC:.c=.s) : %.s : %.c + @echo $(MSG_ASMFROMC) $< to $@ + $(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ + +# Compile: create assembler files from C source files. ARM only +$(SRCARM:.c=.s) : %.s : %.c + @echo $(MSG_ASMFROMC_ARM) $< to $@ + $(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo $(MSG_CLEANING) + $(REMOVE) $(OUTDIR)/$(TARGET).map + $(REMOVE) $(OUTDIR)/$(TARGET).elf + $(REMOVE) $(OUTDIR)/$(TARGET).hex + $(REMOVE) $(OUTDIR)/$(TARGET).bin + $(REMOVE) $(OUTDIR)/$(TARGET).sym + $(REMOVE) $(OUTDIR)/$(TARGET).lss + $(REMOVE) $(ALLOBJ) + $(REMOVE) $(LSTFILES) + $(REMOVE) $(DEPFILES) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRCARM:.c=.s) + $(REMOVE) $(CPPSRC:.cpp=.s) + $(REMOVE) $(CPPSRCARM:.cpp=.s) + +## Create object files directory - now done if special make target +##$(shell mkdir $(OBJDIR) 2>/dev/null) + +# Include the dependency files. +##-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) +-include $(wildcard dep/*) + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex bin lss sym clean clean_list program createdirs + diff --git a/STM32F10x_64k_20k_flash.ld b/STM32F10x_64k_20k_flash.ld new file mode 100644 index 0000000..d378788 --- /dev/null +++ b/STM32F10x_64k_20k_flash.ld @@ -0,0 +1,251 @@ +/* +Default linker script for STM32F10x_64K_20K +Copyright RAISONANCE S.A.S. 2008 +*/ + +/* include the common STM32F10x sub-script */ + +/* Common part of the linker scripts for STM32 devices*/ + + +/* default stack sizes. + +These are used by the startup in order to allocate stacks for the different modes. +*/ + +__Stack_Size = 1024 ; + +PROVIDE ( _Stack_Size = __Stack_Size ) ; + +__Stack_Init = _estack - __Stack_Size ; + +/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/ +PROVIDE ( _Stack_Init = __Stack_Init ) ; + +/* +There will be a link error if there is not this amount of RAM free at the end. +*/ +_Minimum_Stack_Size = 0x100 ; + + +/* include the memory spaces definitions sub-script */ +/* +Linker subscript for STM32F10x definitions with 64K Flash and 20K RAM */ + +/* Memory Spaces Definitions */ + +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K + FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 + EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 +} + +/* higher address of the user mode stack */ +_estack = 0x20005000; + + + +/* include the sections management sub-script for FLASH mode */ +/* +Common part of the linker scripts for STR71x devices in FLASH mode +(that is, the FLASH is seen at 0) +Copyright RAISONANCE 2005 +You can use, modify and distribute thisfile freely, but without any waranty. +*/ + + + +/* Sections Definitions */ + +SECTIONS +{ + /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */ + .flashtext : + { + . = ALIGN(4); + *(.flashtext) /* Startup code */ + . = ALIGN(4); + } >FLASH + + + /* the program code is stored in the .text section, which goes to Flash */ + .text : + { + . = ALIGN(4); + + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + + . = ALIGN(4); + _etext = .; + /* This is used by the startup in order to initialize the .data secion */ + _sidata = _etext; + } >FLASH + + + + /* This is the initialized data section + The program executes knowing that the data is in the RAM + but the loader puts the initial values in the FLASH (inidata). + It is one task of the startup to copy the initial values from FLASH to RAM. */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _sdata = . ; + + *(.data) + *(.data.*) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _edata = . ; + } >RAM + + + + /* This is the uninitialized data section */ + .bss : + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; + + *(.bss) + *(COMMON) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _ebss = . ; + } >RAM + + PROVIDE ( end = _ebss ); + PROVIDE ( _end = _ebss ); + + /* This is the user stack section + This is just to check that there is enough RAM left for the User mode stack + It should generate an error if it's full. + */ + ._usrstack : + { + . = ALIGN(4); + _susrstack = . ; + + . = . + _Minimum_Stack_Size ; + + . = ALIGN(4); + _eusrstack = . ; + } >RAM + + + + /* this is the FLASH Bank1 */ + /* the C or assembly source must explicitly place the code or data there + using the "section" attribute */ + .b1text : + { + *(.b1text) /* remaining code */ + *(.b1rodata) /* read-only data (constants) */ + *(.b1rodata*) + } >FLASHB1 + + /* this is the EXTMEM */ + /* the C or assembly source must explicitly place the code or data there + using the "section" attribute */ + + /* EXTMEM Bank0 */ + .eb0text : + { + *(.eb0text) /* remaining code */ + *(.eb0rodata) /* read-only data (constants) */ + *(.eb0rodata*) + } >EXTMEMB0 + + /* EXTMEM Bank1 */ + .eb1text : + { + *(.eb1text) /* remaining code */ + *(.eb1rodata) /* read-only data (constants) */ + *(.eb1rodata*) + } >EXTMEMB1 + + /* EXTMEM Bank2 */ + .eb2text : + { + *(.eb2text) /* remaining code */ + *(.eb2rodata) /* read-only data (constants) */ + *(.eb2rodata*) + } >EXTMEMB2 + + /* EXTMEM Bank0 */ + .eb3text : + { + *(.eb3text) /* remaining code */ + *(.eb3rodata) /* read-only data (constants) */ + *(.eb3rodata*) + } >EXTMEMB3 + + + + /* after that it's only debugging information. */ + + /* remove the debugging information from the standard libraries */ + DISCARD : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} + diff --git a/Screen.c b/Screen.c new file mode 100644 index 0000000..a0f3035 --- /dev/null +++ b/Screen.c @@ -0,0 +1,696 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Screen.c +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech Ltd. +// Web: www.jyetech.com +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// +//----------------------------------------------------------------------------- +// Includes +//----------------------------------------------------------------------------- + +#include "Common.h" +#include "Board.h" +#include "Screen.h" + +// ========================================================== +// File Scope Variables +// ========================================================== +// + +const U8 DSO_font[(112/8) * 35] = { +/*------------------------------------------------------------------------------ +; 源文件 / 文字 : DSO +; 宽×高(像素): 110×56 +------------------------------------------------------------------------------*/ +0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x00,0x03,0xFE,0x00,0x00,0x3F,0xFF, +0xFF,0x00,0x00,0x00,0xFF,0xFC,0x60,0x00,0x1F,0xFF,0xC0,0x00,0x3F,0xFF,0xFF,0xF0, +0x00,0x01,0xFC,0x1F,0xE0,0x00,0x7F,0x07,0xF0,0x00,0x07,0xFE,0x03,0xFC,0x00,0x03, +0xF0,0x0F,0xE0,0x00,0xFC,0x01,0xF8,0x00,0x01,0xFE,0x00,0xFF,0x00,0x07,0xF0,0x07, +0xE0,0x03,0xF8,0x00,0xFE,0x00,0x01,0xFE,0x00,0x7F,0x80,0x0F,0xE0,0x03,0xE0,0x07, +0xF8,0x00,0x7F,0x00,0x01,0xFE,0x00,0x3F,0xC0,0x0F,0xE0,0x01,0xE0,0x07,0xF0,0x00, +0x7F,0x80,0x01,0xFE,0x00,0x1F,0xE0,0x1F,0xE0,0x01,0xE0,0x0F,0xF0,0x00,0x3F,0x80, +0x01,0xFE,0x00,0x1F,0xE0,0x1F,0xE0,0x00,0xE0,0x1F,0xE0,0x00,0x3F,0xC0,0x01,0xFE, +0x00,0x0F,0xF0,0x1F,0xF0,0x00,0xE0,0x1F,0xE0,0x00,0x3F,0xC0,0x01,0xFE,0x00,0x0F, +0xF8,0x1F,0xF0,0x00,0xE0,0x3F,0xE0,0x00,0x3F,0xE0,0x01,0xFE,0x00,0x0F,0xF8,0x1F, +0xFC,0x00,0x60,0x3F,0xC0,0x00,0x1F,0xE0,0x01,0xFE,0x00,0x07,0xF8,0x1F,0xFF,0x00, +0x00,0x3F,0xC0,0x00,0x1F,0xE0,0x01,0xFE,0x00,0x07,0xFC,0x0F,0xFF,0xC0,0x00,0x7F, +0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07,0xFC,0x0F,0xFF,0xF8,0x00,0x7F,0xC0,0x00, +0x1F,0xF0,0x01,0xFE,0x00,0x07,0xFC,0x07,0xFF,0xFE,0x00,0x7F,0xC0,0x00,0x1F,0xF0, +0x01,0xFE,0x00,0x07,0xFC,0x03,0xFF,0xFF,0x80,0x7F,0xC0,0x00,0x1F,0xF0,0x01,0xFE, +0x00,0x07,0xFC,0x01,0xFF,0xFF,0xC0,0x7F,0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07, +0xFC,0x00,0x7F,0xFF,0xE0,0x7F,0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07,0xFC,0x00, +0x1F,0xFF,0xF0,0x7F,0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07,0xFC,0x00,0x03,0xFF, +0xF0,0x7F,0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07,0xFC,0x00,0x00,0x7F,0xF8,0x7F, +0xC0,0x00,0x1F,0xF0,0x01,0xFE,0x00,0x07,0xF8,0x30,0x00,0x1F,0xF8,0x3F,0xC0,0x00, +0x1F,0xE0,0x01,0xFE,0x00,0x07,0xF8,0x38,0x00,0x0F,0xF8,0x3F,0xC0,0x00,0x1F,0xE0, +0x01,0xFE,0x00,0x0F,0xF8,0x38,0x00,0x0F,0xF8,0x3F,0xE0,0x00,0x3F,0xE0,0x01,0xFE, +0x00,0x0F,0xF0,0x3C,0x00,0x07,0xF8,0x1F,0xE0,0x00,0x3F,0xC0,0x01,0xFE,0x00,0x0F, +0xE0,0x3C,0x00,0x07,0xF8,0x1F,0xE0,0x00,0x3F,0xC0,0x01,0xFE,0x00,0x1F,0xE0,0x3E, +0x00,0x07,0xF0,0x0F,0xF0,0x00,0x7F,0x80,0x01,0xFE,0x00,0x1F,0xC0,0x3E,0x00,0x07, +0xF0,0x0F,0xF0,0x00,0x7F,0x80,0x01,0xFE,0x00,0x3F,0x80,0x3F,0x00,0x07,0xF0,0x07, +0xF0,0x00,0x7F,0x00,0x01,0xFF,0x00,0x7E,0x00,0x3F,0x80,0x0F,0xE0,0x03,0xF8,0x00, +0xFE,0x00,0x03,0xFF,0x81,0xFC,0x00,0x3F,0xC0,0x1F,0xC0,0x00,0xFC,0x01,0xFC,0x00, +0x3F,0xFF,0xFF,0xE0,0x00,0x3B,0xF0,0x3F,0x80,0x00,0x7F,0x07,0xF0,0x00,0x3F,0xFF, +0xFF,0x00,0x00,0x30,0xFF,0xFE,0x00,0x00,0x1F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x1F,0xF0,0x00,0x00,0x03,0xFE,0x00,0x00 +}; + +FONT DSOm = { + (U8*)DSO_font, + 112, + 35, + 112, + 35, + 0 + }; + + +const U8 Shell_font[(120/8) * 36] = { +/*------------------------------------------------------------------------------ +; 源文件 / 文字 : Shell +; 宽×高(像素): 119×57 +------------------------------------------------------------------------------*/ +0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, +0xE0,0x0F,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x03,0xF8,0x0F,0xE0,0x03,0x00, +0x01,0xC0,0x0C,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x0E,0x00,0x00, +0xE0,0x0C,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x0C,0x00,0x00,0x70, +0x0C,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x18,0x1F,0xF0,0x38,0x0C, +0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x18,0x70,0x1E,0x18,0x0C,0x60, +0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x30,0xC0,0x07,0x1C,0x0C,0x60,0x00, +0x00,0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x31,0x80,0x03,0x0C,0x0C,0x60,0x00,0x00, +0x00,0x00,0x00,0x03,0x18,0x0C,0x60,0x31,0x80,0x01,0x8C,0x0C,0x60,0x00,0x00,0x00, +0x00,0x00,0x03,0x18,0x0C,0x60,0x31,0x80,0x01,0xFC,0x0C,0x63,0xFC,0x00,0x00,0x7F, +0xC0,0x03,0x18,0x0C,0x60,0x31,0xC0,0x00,0x00,0x0C,0x6E,0x07,0x00,0x01,0xC0,0x70, +0x03,0x18,0x0C,0x60,0x30,0xE0,0x00,0x00,0x0C,0x78,0x03,0x80,0x07,0x00,0x1C,0x03, +0x18,0x0C,0x60,0x38,0x3C,0x00,0x00,0x0C,0x70,0x00,0xC0,0x0E,0x00,0x0E,0x03,0x18, +0x0C,0x60,0x18,0x07,0xE0,0x00,0x0C,0x60,0x00,0xC0,0x1C,0x00,0x07,0x03,0x18,0x0C, +0x60,0x1C,0x00,0x3E,0x00,0x0C,0xC7,0xF0,0x60,0x18,0x3F,0x83,0x03,0x18,0x0C,0x60, +0x0E,0x00,0x07,0x80,0x0C,0x1C,0x38,0x60,0x30,0xE0,0xE1,0x83,0x18,0x0C,0x60,0x03, +0x80,0x00,0xE0,0x0C,0x18,0x18,0x60,0x31,0x80,0x31,0x83,0x18,0x0C,0x60,0x00,0xF0, +0x00,0x38,0x0C,0x30,0x0C,0x60,0x31,0x80,0x31,0x83,0x18,0x0C,0x60,0x00,0x3F,0x00, +0x1C,0x0C,0x30,0x0C,0x60,0x63,0x00,0x18,0xC3,0x18,0x0C,0x60,0x00,0x01,0xF0,0x0C, +0x0C,0x60,0x0C,0x60,0x63,0x00,0x18,0xC3,0x18,0x0C,0x60,0x00,0x00,0x1C,0x0E,0x0C, +0x60,0x0C,0x60,0x63,0xFF,0xF8,0xC3,0x18,0x0C,0x60,0x00,0x00,0x07,0x06,0x0C,0x60, +0x0C,0x60,0x60,0x00,0x00,0xC3,0x18,0x0C,0x60,0x00,0x00,0x01,0x86,0x0C,0x60,0x0C, +0x60,0x60,0x00,0x00,0xC3,0x18,0x0C,0x60,0x7F,0x80,0x00,0xC6,0x0C,0x60,0x0C,0x60, +0x60,0x00,0x00,0xC3,0x18,0x0C,0x60,0x71,0x80,0x00,0xC6,0x0C,0x60,0x0C,0x60,0x63, +0xFF,0xFF,0xC3,0x18,0x0C,0x60,0x71,0xC0,0x00,0xC6,0x0C,0x60,0x0C,0x60,0x63,0x00, +0x00,0x03,0x18,0x0C,0x60,0x70,0xC0,0x01,0xC6,0x0C,0x60,0x0C,0x60,0x33,0x00,0x00, +0x03,0x18,0x0C,0x60,0x38,0x60,0x01,0x8C,0x0C,0x60,0x0C,0x60,0x31,0x80,0x00,0x03, +0x18,0x0C,0x60,0x38,0x38,0x0F,0x0C,0x0C,0x60,0x0C,0x60,0x30,0xE0,0x3F,0xC3,0x18, +0x0C,0x60,0x1C,0x0F,0xF8,0x1C,0x0C,0x60,0x0C,0x60,0x18,0x3F,0xF1,0x83,0x18,0x0C, +0x60,0x1E,0x00,0x00,0x18,0x0C,0x60,0x0C,0x60,0x1C,0x00,0x03,0x83,0x18,0x0C,0x60, +0x0F,0x00,0x00,0x70,0x0C,0x60,0x0C,0x60,0x0E,0x00,0x07,0x03,0x18,0x0C,0x60,0x03, +0x80,0x00,0xE0,0x0C,0x60,0x0C,0x60,0x07,0x00,0x0E,0x03,0x18,0x0C,0x60,0x01,0xF0, +0x07,0x80,0x0C,0x60,0x0C,0x60,0x01,0xC0,0x78,0x03,0x18,0x0C,0x60,0x00,0x3F,0xFC, +0x00,0x0F,0xE0,0x0F,0xE0,0x00,0x7F,0xC0,0x03,0xF8,0x0F,0xE0 +}; + +FONT Shell = { + (U8*)Shell_font, + 120, + 36, + 120, + 36, + 0 + }; + + +const U8 DSO_Shell_font[(88/8) * 12] = { +/*------------------------------------------------------------------------------ +; 源文件 / 文字 : DSO Shell +; 宽×高(像素): 85×22 +------------------------------------------------------------------------------*/ +0xFF,0x80,0x7A,0x03,0xE0,0x00,0xF4,0xF0,0x00,0x1E,0xF0,0x38,0xE0,0xC6,0x0E,0x38, +0x01,0x8C,0x70,0x00,0x0E,0x70,0x38,0x71,0xC2,0x1C,0x1C,0x03,0x84,0x70,0x00,0x0E, +0x70,0x38,0x31,0xC2,0x18,0x0C,0x03,0x84,0x77,0x07,0x0E,0x70,0x38,0x39,0xE0,0x38, +0x0E,0x03,0xC0,0x7B,0x8D,0x8E,0x70,0x38,0x38,0xF8,0x38,0x0E,0x01,0xF0,0x73,0x9D, +0xCE,0x70,0x38,0x38,0x3E,0x38,0x0E,0x00,0x7C,0x73,0x9F,0xCE,0x70,0x38,0x39,0x0F, +0x38,0x0E,0x02,0x1E,0x73,0x9C,0x0E,0x70,0x38,0x39,0x07,0x18,0x0C,0x02,0x0E,0x73, +0x9C,0x0E,0x70,0x38,0x71,0x87,0x1C,0x1C,0x03,0x0E,0x73,0x9C,0x0E,0x70,0x38,0xE1, +0xC6,0x0E,0x38,0x03,0x8C,0x73,0x8E,0x4E,0x70,0xFF,0x81,0x3C,0x03,0xE0,0x02,0x78, +0xFB,0xC7,0x9F,0xF8 +}; + +FONT DSO_Shell = { + (U8*)DSO_Shell_font, + 88, + 12, + 88, + 12, + 0 + }; + +#define ASC8X16_Use_Display_Char_Only +const U8 Font_ASC8X16[128*16] = { +#ifndef ASC8X16_Use_Display_Char_Only + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x00 + 0x00,0x00,0x7E,0x81,0xA5,0x81,0x81,0xBD,0x99,0x81,0x81,0x7E,0x00,0x00,0x00,0x00, //0x01 + 0x00,0x00,0x7E,0xFF,0xDB,0xFF,0xFF,0xC3,0xE7,0xFF,0xFF,0x7E,0x00,0x00,0x00,0x00, //0x02 + 0x00,0x00,0x00,0x00,0x6C,0xFE,0xFE,0xFE,0xFE,0x7C,0x38,0x10,0x00,0x00,0x00,0x00, //0x03 + 0x00,0x00,0x00,0x00,0x10,0x38,0x7C,0xFE,0x7C,0x38,0x10,0x00,0x00,0x00,0x00,0x00, //0x04 + 0x00,0x00,0x00,0x18,0x3C,0x3C,0xE7,0xE7,0xE7,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x05 + 0x00,0x00,0x00,0x18,0x3C,0x7E,0xFF,0xFF,0x7E,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x06 + 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00, //0x07 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //0x08 + 0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,0x00, //0x09 + 0xFF,0xFF,0xFF,0xFF,0xFF,0xC3,0x99,0xBD,0xBD,0x99,0xC3,0xFF,0xFF,0xFF,0xFF,0xFF, //0x0A + 0x00,0x00,0x1E,0x0E,0x1A,0x32,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00, //0x0B + 0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00, //0x0C + 0x00,0x00,0x3F,0x33,0x3F,0x30,0x30,0x30,0x30,0x70,0xF0,0xE0,0x00,0x00,0x00,0x00, //0x0D + 0x00,0x00,0x7F,0x63,0x7F,0x63,0x63,0x63,0x63,0x67,0xE7,0xE6,0xC0,0x00,0x00,0x00, //0x0E + 0x00,0x00,0x00,0x18,0x18,0xDB,0x3C,0xE7,0x3C,0xDB,0x18,0x18,0x00,0x00,0x00,0x00, //0x0F + 0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFE,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00, //0x10 + 0x00,0x02,0x06,0x0E,0x1E,0x3E,0xFE,0x3E,0x1E,0x0E,0x06,0x02,0x00,0x00,0x00,0x00, //0x11 + 0x00,0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00,0x00, //0x12 + 0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x66,0x00,0x00,0x00,0x00, //0x13 + 0x00,0x00,0x7F,0xDB,0xDB,0xDB,0x7B,0x1B,0x1B,0x1B,0x1B,0x1B,0x00,0x00,0x00,0x00, //0x14 + 0x00,0x7C,0xC6,0x60,0x38,0x6C,0xC6,0xC6,0x6C,0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00, //0x15 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0xFE,0xFE,0x00,0x00,0x00,0x00, //0x16 + 0x00,0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x7E,0x3C,0x18,0x7E,0x00,0x00,0x00,0x00, //0x17 + 0x00,0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, //0x18 + 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00, //0x19 + 0x00,0x00,0x00,0x00,0x00,0x18,0x0C,0xFE,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00, //0x1A + 0x00,0x00,0x00,0x00,0x00,0x30,0x60,0xFE,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00, //0x1B + 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xFE,0x00,0x00,0x00,0x00,0x00,0x00, //0x1C + 0x00,0x00,0x00,0x00,0x00,0x28,0x6C,0xFE,0x6C,0x28,0x00,0x00,0x00,0x00,0x00,0x00, //0x1D + 0x00,0x00,0x00,0x00,0x10,0x38,0x38,0x7C,0x7C,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00, //0x1E + 0x00,0x00,0x00,0x00,0xFE,0xFE,0x7C,0x7C,0x38,0x38,0x10,0x00,0x00,0x00,0x00,0x00, //0x1F +#endif + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x20' ' + 0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00, //0x21'!' + 0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x22'"' + 0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00, //0x23'#' + 0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06,0x06,0x86,0xC6,0x7C,0x18,0x18,0x00,0x00, //0x24'$' + 0x00,0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18,0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00, //0x25'%' + 0x00,0x00,0x38,0x6C,0x6C,0x38,0x76,0xDC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x26'&' + 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x27''' + 0x00,0x00,0x0C,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00, //0x28'(' + 0x00,0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00, //0x29')' + 0x00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00, //0x2A'*' + 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00, //0x2B'+' + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00, //0x2C',' + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x2D'-' + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00, //0x2E'.' + 0x00,0x00,0x00,0x00,0x02,0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00, //0x2F'/' + 0x00,0x00,0x38,0x6C,0xC6,0xC6,0xD6,0xD6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00, //0x30'0' + 0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00, //0x31'1' + 0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00, //0x32'2' + 0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x33'3' + 0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00, //0x34'4' + 0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x35'5' + 0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x36'6' + 0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00, //0x37'7' + 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x38'8' + 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00, //0x39'9' + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00, //0x3A':' + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00, //0x3B';' + 0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00, //0x3C'<' + 0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x3D'=' + 0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00, //0x3E'>' + 0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00, //0x3F'?' + 0x00,0x00,0x00,0x7C,0xC6,0xC6,0xDE,0xDE,0xDE,0xDC,0xC0,0x7C,0x00,0x00,0x00,0x00, //0x40'@' + 0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x41'A' + 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00, //0x42'B' + 0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00, //0x43'C' + 0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00, //0x44'D' + 0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00, //0x45'E' + 0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00, //0x46'F' + 0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE,0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00, //0x47'G' + 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x48'H' + 0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x49'I' + 0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00, //0x4A'J' + 0x00,0x00,0xE6,0x66,0x66,0x6C,0x78,0x78,0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00, //0x4B'K' + 0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00, //0x4C'L' + 0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x4D'M' + 0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x4E'N' + 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x4F'O' + 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00, //0x50'P' + 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00, //0x51'Q' + 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00, //0x52'R' + 0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C,0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x53'S' + 0x00,0x00,0x7E,0x7E,0x5A,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x54'T' + 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x55'U' + 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00, //0x56'V' + 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0xD6,0xFE,0xEE,0x6C,0x00,0x00,0x00,0x00, //0x57'W' + 0x00,0x00,0xC6,0xC6,0x6C,0x7C,0x38,0x38,0x7C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x58'X' + 0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x59'Y' + 0x00,0x00,0xFE,0xC6,0x86,0x0C,0x18,0x30,0x60,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00, //0x5A'Z' + 0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00,0x00,0x00, //0x5B'[' + 0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0E,0x06,0x02,0x00,0x00,0x00,0x00, //0x5C'\' + 0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00,0x00, //0x5D']' + 0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x5E'^' + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00, //0x5F'_' + 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x60'`' + 0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x61'a' + 0x00,0x00,0xE0,0x60,0x60,0x78,0x6C,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00, //0x62'b' + 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x63'c' + 0x00,0x00,0x1C,0x0C,0x0C,0x3C,0x6C,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x64'd' + 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x65'e' + 0x00,0x00,0x38,0x6C,0x64,0x60,0xF0,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00, //0x66'f' + 0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00, //0x67'g' + 0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00, //0x68'h' + 0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x69'i' + 0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, //0x6A'j' + 0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00, //0x6B'k' + 0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x6C'l' + 0x00,0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6,0xD6,0xD6,0xD6,0xC6,0x00,0x00,0x00,0x00, //0x6D'm' + 0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00, //0x6E'n' + 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x6F'o' + 0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00, //0x70'p' + 0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00, //0x71'q' + 0x00,0x00,0x00,0x00,0x00,0xDC,0x76,0x66,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00, //0x72'r' + 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x60,0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x73's' + 0x00,0x00,0x10,0x30,0x30,0xFC,0x30,0x30,0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00, //0x74't' + 0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x75'u' + 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00, //0x76'v' + 0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xD6,0xD6,0xD6,0xFE,0x6C,0x00,0x00,0x00,0x00, //0x77'w' + 0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00, //0x78'x' + 0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00, //0x79'y' + 0x00,0x00,0x00,0x00,0x00,0xFE,0xCC,0x18,0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00, //0x7A'z' + 0x00,0x00,0x0E,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00, //0x7B'' + 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, //0x7C'|' + 0x00,0x00,0x70,0x18,0x18,0x18,0x0E,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00, //0x7D'' + 0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x7E'~' +// 0x00,0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0x00,0x00,0x00,0x00,0x00, //0x7F'' + 0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7E,0x62,0x60,0x60,0xC0, +// 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xC0,0x00,0x00,0x00, //0xE6 -- Greek (u) +#ifdef ASC8X16_USE_EXTEND_CHARACTER_SET + 0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x0C,0x06,0x7C,0x00,0x00, //0x80 + 0x00,0x00,0xCC,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x81 + 0x00,0x0C,0x18,0x30,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x82 + 0x00,0x10,0x38,0x6C,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x83 + 0x00,0x00,0xCC,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x84 + 0x00,0x60,0x30,0x18,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x85 + 0x00,0x38,0x6C,0x38,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x86 + 0x00,0x00,0x00,0x00,0x3C,0x66,0x60,0x60,0x66,0x3C,0x0C,0x06,0x3C,0x00,0x00,0x00, //0x87 + 0x00,0x10,0x38,0x6C,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x88 + 0x00,0x00,0xC6,0x00,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x89 + 0x00,0x60,0x30,0x18,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x8A + 0x00,0x00,0x66,0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x8B + 0x00,0x18,0x3C,0x66,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x8C + 0x00,0x60,0x30,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0x8D + 0x00,0xC6,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x8E + 0x38,0x6C,0x38,0x00,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0x8F + 0x18,0x30,0x60,0x00,0xFE,0x66,0x60,0x7C,0x60,0x60,0x66,0xFE,0x00,0x00,0x00,0x00, //0x90 + 0x00,0x00,0x00,0x00,0x00,0xCC,0x76,0x36,0x7E,0xD8,0xD8,0x6E,0x00,0x00,0x00,0x00, //0x91 + 0x00,0x00,0x3E,0x6C,0xCC,0xCC,0xFE,0xCC,0xCC,0xCC,0xCC,0xCE,0x00,0x00,0x00,0x00, //0x92 + 0x00,0x10,0x38,0x6C,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x93 + 0x00,0x00,0xC6,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x94 + 0x00,0x60,0x30,0x18,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x95 + 0x00,0x30,0x78,0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x96 + 0x00,0x60,0x30,0x18,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0x97 + 0x00,0x00,0xC6,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0x78,0x00, //0x98 + 0x00,0xC6,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x99 + 0x00,0xC6,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0x9A + 0x00,0x18,0x18,0x3C,0x66,0x60,0x60,0x60,0x66,0x3C,0x18,0x18,0x00,0x00,0x00,0x00, //0x9B + 0x00,0x38,0x6C,0x64,0x60,0xF0,0x60,0x60,0x60,0x60,0xE6,0xFC,0x00,0x00,0x00,0x00, //0x9C + 0x00,0x00,0x66,0x66,0x3C,0x18,0x7E,0x18,0x7E,0x18,0x18,0x18,0x00,0x00,0x00,0x00, //0x9D + 0x00,0xF8,0xCC,0xCC,0xF8,0xC4,0xCC,0xDE,0xCC,0xCC,0xCC,0xC6,0x00,0x00,0x00,0x00, //0x9E + 0x00,0x0E,0x1B,0x18,0x18,0x18,0x7E,0x18,0x18,0x18,0x18,0x18,0xD8,0x70,0x00,0x00, //0x9F + 0x00,0x18,0x30,0x60,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0xA0 + 0x00,0x0C,0x18,0x30,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00, //0xA1 + 0x00,0x18,0x30,0x60,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0xA2 + 0x00,0x18,0x30,0x60,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00, //0xA3 + 0x00,0x00,0x76,0xDC,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00, //0xA4 + 0x76,0xDC,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0xA5 + 0x00,0x3C,0x6C,0x6C,0x3E,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xA6 + 0x00,0x38,0x6C,0x6C,0x38,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xA7 + 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60,0xC0,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00, //0xA8 + 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00, //0xA9 + 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00, //0xAA + 0x00,0xC0,0xC0,0xC2,0xC6,0xCC,0x18,0x30,0x60,0xDC,0x86,0x0C,0x18,0x3E,0x00,0x00, //0xAB + 0x00,0xC0,0xC0,0xC2,0xC6,0xCC,0x18,0x30,0x66,0xCE,0x9E,0x3E,0x06,0x06,0x00,0x00, //0xAC + 0x00,0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x3C,0x3C,0x3C,0x18,0x00,0x00,0x00,0x00, //0xAD + 0x00,0x00,0x00,0x00,0x00,0x36,0x6C,0xD8,0x6C,0x36,0x00,0x00,0x00,0x00,0x00,0x00, //0xAE + 0x00,0x00,0x00,0x00,0x00,0xD8,0x6C,0x36,0x6C,0xD8,0x00,0x00,0x00,0x00,0x00,0x00, //0xAF + 0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44, //0xB0 + 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, //0xB1 + 0xDD,0x77,0xDD,0x77,0xDD,0x77,0xDD,0x77,0xDD,0x77,0xDD,0x77,0xDD,0x77,0xDD,0x77, //0xB2 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xB3 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xB4 + 0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xB5 + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xB6 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xB7 + 0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xB8 + 0x36,0x36,0x36,0x36,0x36,0xF6,0x06,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xB9 + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xBA + 0x00,0x00,0x00,0x00,0x00,0xFE,0x06,0xF6,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xBB + 0x36,0x36,0x36,0x36,0x36,0xF6,0x06,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xBC + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xBD + 0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xBE + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xBF + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xC0 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xC1 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xC2 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xC3 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xC4 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xC5 + 0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xC6 + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xC7 + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xC8 + 0x00,0x00,0x00,0x00,0x00,0x3F,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xC9 + 0x36,0x36,0x36,0x36,0x36,0xF7,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xCA + 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xF7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xCB + 0x36,0x36,0x36,0x36,0x36,0x37,0x30,0x37,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xCC + 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xCD + 0x36,0x36,0x36,0x36,0x36,0xF7,0x00,0xF7,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xCE + 0x18,0x18,0x18,0x18,0x18,0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xCF + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xD0 + 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xD1 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xD2 + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xD3 + 0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xD4 + 0x00,0x00,0x00,0x00,0x00,0x1F,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xD5 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xD6 + 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0xFF,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, //0xD7 + 0x18,0x18,0x18,0x18,0x18,0xFF,0x18,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xD8 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xD9 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xDA + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //0xDB + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //0xDC + 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0, //0xDD + 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, //0xDE + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xDF + 0x00,0x00,0x00,0x00,0x00,0x76,0xDC,0xD8,0xD8,0xD8,0xDC,0x76,0x00,0x00,0x00,0x00, //0xE0 + 0x00,0x00,0x78,0xCC,0xCC,0xCC,0xD8,0xCC,0xC6,0xC6,0xC6,0xCC,0x00,0x00,0x00,0x00, //0xE1 + 0x00,0x00,0xFE,0xC6,0xC6,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00, //0xE2 + 0x00,0x00,0x00,0x00,0xFE,0x6C,0x6C,0x6C,0x6C,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00, //0xE3 + 0x00,0x00,0x00,0xFE,0xC6,0x60,0x30,0x18,0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00, //0xE4 + 0x00,0x00,0x00,0x00,0x00,0x7E,0xD8,0xD8,0xD8,0xD8,0xD8,0x70,0x00,0x00,0x00,0x00, //0xE5 + 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xC0,0x00,0x00,0x00, //0xE6 -- (u) micro + 0x00,0x00,0x00,0x00,0x76,0xDC,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, //0xE7 + 0x00,0x00,0x00,0x7E,0x18,0x3C,0x66,0x66,0x66,0x3C,0x18,0x7E,0x00,0x00,0x00,0x00, //0xE8 + 0x00,0x00,0x00,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00, //0xE9 + 0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x6C,0x6C,0x6C,0xEE,0x00,0x00,0x00,0x00, //0xEA + 0x00,0x00,0x1E,0x30,0x18,0x0C,0x3E,0x66,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00, //0xEB + 0x00,0x00,0x00,0x00,0x00,0x7E,0xDB,0xDB,0xDB,0x7E,0x00,0x00,0x00,0x00,0x00,0x00, //0xEC + 0x00,0x00,0x00,0x03,0x06,0x7E,0xDB,0xDB,0xF3,0x7E,0x60,0xC0,0x00,0x00,0x00,0x00, //0xED + 0x00,0x00,0x1C,0x30,0x60,0x60,0x7C,0x60,0x60,0x60,0x30,0x1C,0x00,0x00,0x00,0x00, //0xEE + 0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00, //0xEF + 0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0xFE,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00, //0xF0 + 0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0xFF,0x00,0x00,0x00,0x00, //0xF1 + 0x00,0x00,0x00,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00,0x7E,0x00,0x00,0x00,0x00, //0xF2 + 0x00,0x00,0x00,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00,0x7E,0x00,0x00,0x00,0x00, //0xF3 + 0x00,0x00,0x0E,0x1B,0x1B,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, //0xF4 + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xD8,0xD8,0xD8,0x70,0x00,0x00,0x00,0x00, //0xF5 + 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x7E,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00, //0xF6 + 0x00,0x00,0x00,0x00,0x00,0x76,0xDC,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00, //0xF7 + 0x00,0x38,0x6C,0x6C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xF8 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xF9 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xFA + 0x00,0x0F,0x0C,0x0C,0x0C,0x0C,0x0C,0xEC,0x6C,0x6C,0x3C,0x1C,0x00,0x00,0x00,0x00, //0xFB + 0x00,0xD8,0x6C,0x6C,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xFC + 0x00,0x70,0xD8,0x30,0x60,0xC8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0xFD + 0x00,0x00,0x00,0x00,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x00,0x00,0x00,0x00,0x00, //0xFE + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //0xFF +#endif +}; + +FONT ASC8X16 = { + (U8 *)Font_ASC8X16, + 8, + 16, + 8, + 16, + 0x20 + }; + +// ===== Function Definitions ================== +// +// ========================================== +// Clear screen +void ClrScreen(void) +{ + FillRect(ScreenX0, ScreenY0, ScreenXsize, ScreenYsize, clBlack); +} + +void SetWindow(U16 x, U16 xsize, U16 y, U16 ysize) +{ + write_comm(0x2A); + + write_data(x >> 8); + write_data(x); + x = x + xsize - 1; + write_data(x >> 8); + write_data(x); + + + write_comm(0x2B); + write_data(y >> 8); + write_data(y); + y = y + ysize - 1; + write_data(y >> 8); + write_data(y); +} + + +// ========================================== +// Fill rectangle area with given color +void FillRect_9325(S16 x, S16 y, S16 xsize, S16 ysize, U16 color) +{ + U32 tmp; + + // Set X start and end address + TFT_CmdWrite(TFT_VAddressStart, x); + TFT_CmdWrite(TFT_VAddressEnd, x + xsize - 1); + // Set Y start and end address + TFT_CmdWrite(TFT_HAddressStart, y); + TFT_CmdWrite(TFT_HAddressEnd, y + ysize - 1); + + // Set data start address in GRAM + TFT_CmdWrite(TFT_DramHAddress, y); + TFT_CmdWrite(TFT_DramVAddress, x); + +// Delay(200); + + // Fill with bgcolor + TFT_AccessGRAM(); + tmp = (U32)xsize * (U32)ysize; + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + while(tmp) { + TFT_Port = (TFT_Port & 0xFF00) | (color >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | (color & 0x00FF); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + tmp--; + } + +// sei(); + + TFT_AccessGRAM_End(); + // Set LCD_nCS high +// BitSet8(LCD_nCS_Port, (1 << LCD_nCS_Bit)); +} + + +// Put at (x, y) a 15X16 character [ch] with [f_color] and [b_color] +// +void PutcGenic_9325(U16 x, U16 y, U8 ch, U16 fgcolor, U16 bgcolor, FONT *font) +{ + U8 tmp, tmp2; + U16 tmp1, tmp3; + U8 *ptmp; + + // Font address + ptmp = (U8 *)font->Array + (ch - font->IndexOfs) * ((font->Xsize + 7)/8) * font->Ysize; + + // Set X start and end address + TFT_CmdWrite(TFT_VAddressStart, x); + TFT_CmdWrite(TFT_VAddressEnd, x + font->Xsize - 1); + // Set Y start and end address + TFT_CmdWrite(TFT_HAddressStart, y); + TFT_CmdWrite(TFT_HAddressEnd, y + font->Ysize - 1); + + // Set data start address in GRAM + TFT_CmdWrite(TFT_DramVAddress, x); + TFT_CmdWrite(TFT_DramHAddress, y); + + TFT_AccessGRAM(); + + // Set up to access Data Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + tmp1 = (font->Xsize * font->Ysize)/8; + while(tmp1) { + tmp = *ptmp; + tmp2 = 8; + while(tmp2) { + tmp3 = (tmp & 0x80) ? fgcolor : bgcolor; + TFT_Port = (TFT_Port & 0xFF00) | (tmp3 >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | (tmp3 & 0x00FF); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + tmp <<= 1; + tmp2--; + } + ptmp++; + tmp1--; + } + + TFT_AccessGRAM_End(); + +} + +// ========================================== +// Fill rectangle area with given color +void FillRect_9341(S16 x, S16 y, S16 xsize, S16 ysize, U16 color) +{ + U32 tmp; + + SetWindow(x, xsize, y, ysize); + +// Delay(200); + + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + + SetToLow(TFT_RS_Port, (1 << TFT_RS_Bit)); +// Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | 0x2C; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + tmp = (U32)xsize * (U32)ysize; + // Set up to access Index Register (RS == 1) + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + while(tmp) { + TFT_Port = (TFT_Port & 0xFF00) | (color >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | (color & 0x00FF); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + tmp--; + } + + // Set TFT_nCS high + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); +} + +// Put at (x, y) a 15X16 character [ch] with [f_color] and [b_color] +// +void PutcGenic_9341(U16 x, U16 y, U8 ch, U16 fgcolor, U16 bgcolor, FONT *font) +{ + U8 tmp, tmp2; + U16 tmp1, tmp3; + U8 *ptmp; + + // Font address + ptmp = (U8 *)font->Array + (ch - font->IndexOfs) * ((font->Xsize + 7)/8) * font->Ysize; + + SetWindow(x, font->Xsize, y, font->Ysize); + + SetToLow(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + + SetToLow(TFT_RS_Port, (1 << TFT_RS_Bit)); +// Delay(2); + + TFT_Port = (TFT_Port & 0xFF00) | 0x2C; + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + SetToHigh(TFT_RS_Port, (1 << TFT_RS_Bit)); + + tmp1 = (font->Xsize * font->Ysize)/8; + while(tmp1) { + tmp = *ptmp; + tmp2 = 8; + while(tmp2) { + tmp3 = (tmp & 0x80) ? fgcolor : bgcolor; + + TFT_Port = (TFT_Port & 0xFF00) | (tmp3 >> 8); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + TFT_Port = (TFT_Port & 0xFF00) | (tmp3 & 0x00FF); + SetToLow(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + SetToHigh(TFT_nWR_Port, (1 << TFT_nWR_Bit)); + + tmp <<= 1; + tmp2--; + } + ptmp++; + tmp1--; + } + + SetToHigh(TFT_nCS_Port, (1 << TFT_nCS_Bit)); + +} + +void FillRect(S16 x, S16 y, S16 xsize, S16 ysize, U16 color) +{ + + if(TFT_Controller == 0x9341) { + FillRect_9341(x, y, xsize, ysize, color); + } + else { + FillRect_9325(x, y, xsize, ysize, color); + } + +} + +void PutsGenic(U16 x, U16 y, U8 *str, U16 fgcolor, U16 bgcolor, FONT *font) +{ + U8 tmp; + + if(TFT_Controller == 0x9341) { + while((tmp = *str++)) { + PutcGenic_9341(x, y, tmp, fgcolor, bgcolor, font); + x += font->CharPitch; + if(x >= ScreenXsize) { + y += font->LinePitch; + x = 0; + } + } + } + else { + while((tmp = *str++)) { + PutcGenic_9325(x, y, tmp, fgcolor, bgcolor, font); + x += font->CharPitch; + if(x >= ScreenXsize) { + y += font->LinePitch; + x = 0; + } + } + } + +} + +void PutcGenic(U16 x, U16 y, U8 ch, U16 fgcolor, U16 bgcolor, FONT *font) +{ + if(TFT_Controller == 0x9341) { + PutcGenic_9341(x, y, ch, fgcolor, bgcolor, font); + } + else { + PutcGenic_9325(x, y, ch, fgcolor, bgcolor, font); + } +} + diff --git a/Screen.h b/Screen.h new file mode 100644 index 0000000..89a8a87 --- /dev/null +++ b/Screen.h @@ -0,0 +1,141 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: Board.h +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech Ltd. +// Web: www.jyetech.com +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// +// + +#ifndef Screen_h + +#define Screen_h + +#include "Common.h" + +// ------------ Display parameters ----------------------- +// Overall display parameters +#define ScreenX0 0 +#define ScreenY0 0 +#define ScreenXsize 320 +#define ScreenYsize 240 + +#define Rbits 0 // Red bits position +#define Gbits 5 // Green bits position +#define Bbits 11 // Blue bits position +#define RGB(R, G, B) (((R >> 3) << Rbits) | ((G >> 2) << Gbits) | ((B >> 3) << Bbits)) + +enum COLOR{ + clBlack = RGB(0, 0, 0), + clWhite = RGB(255, 255, 255), + clRed = RGB(255, 0, 0), + clGreen = RGB(0, 255, 0), + clBlue = RGB(0, 0, 255), + clYellow = RGB(255, 255, 0), + clGainsboro = RGB(220, 220, 220), + clNavy = RGB(0, 0, 128), + clAqua = RGB(0, 255, 255), + clHotpink = RGB(255, 105, 180), + clOrange = RGB(255, 165, 0), + clDeepskyblue = RGB(0, 191, 255), + clDimgray = RGB(105, 105, 105), + cllightsalmon = RGB(255, 160, 122), + cllightcoral = RGB(240, 128, 128), + clpaleturquoise = RGB(175, 238, 238), + clturquoise = RGB(64, 224, 208), + clViolet = RGB(238, 130, 238), + clGray1 = RGB(90, 90, 90), + clGray2 = RGB(220, 220, 220), + clGray3 = RGB(240, 240, 240), + clDarkgray = RGB(169, 169, 169), + clSkyblue = RGB(135, 206, 235), + clChocolate = RGB(210, 105, 30), + clMediumseagreen = RGB(60, 179, 113), + clPeachpuff = RGB(255, 218, 185), + clSeagreen = RGB(46, 139, 87), + + clBG1 = clGainsboro, + + clActiveItem1 = clAqua, + clActiveItem2 = clturquoise, + + clBtnBG1 = clOrange, + clBtnBG2 = clBlue, + clBtnBG3 = clGainsboro, + clBtnBG4 = clSkyblue, + clBtnBG5 = clRed, + + clBtnFG1 = clBlack, + clBtnFG2 = clWhite, + + clCh1 = clYellow, + clTB = clGreen, + clTrigger = clHotpink, + + clCursorT = clMediumseagreen, + clCursorV = clOrange, + clCursorActive = clAqua, + clMeasurement = clGray3, +} ; + +typedef struct { + U8 *Array; + U16 Xsize; + U8 Ysize; + U16 CharPitch; + U8 LinePitch; + U8 IndexOfs; + } FONT; + + +// Display Panel +// ======================================================= +// Display parameters +#define WWindowx0 10 +#define WWindowy0 17 +#define WWindowSizex 300 +#define WWindowSizey 200 + +#define WDsize 300 // Wave display size +#define HBarSize 140 // HPos indicator length + +// =========================================================== +// Declarations of external variables +// =========================================================== +// +extern FONT DSOm; +extern FONT Shell; +extern FONT DSO_Shell; +extern FONT ASC8X16; + +// =========================================================== +// Function Prototype Declarations +// =========================================================== +// +void ClrScreen(void); +void SetWindow(U16 x, U16 xsize, U16 y, U16 ysize); +void FillRect(S16 x, S16 y, S16 xsize, S16 ysize, U16 color); +void PutcGenic(U16 x, U16 y, U8 ch, U16 fgcolor, U16 bgcolor, FONT *font); +void PutsGenic(U16 x, U16 y, U8 *str, U16 fgcolor, U16 bgcolor, FONT *font); + +#endif + diff --git a/libdso150.a b/libdso150.a new file mode 100644 index 0000000000000000000000000000000000000000..e5d9228530d6695c0449db119ead2e5e257e640f GIT binary patch literal 43452 zcmeIb3w%`7y*9jNat|Rl5GIoenIw1(VlIG?a3mxcNj7MNXfdE4rb7mG46?(k|Qe^-2dW#BY z%vL_?6NM1>3laa!-|xS*GFaUy#OJ*?)C*z1?>;Dm{r>W9AwJLjluL-w_oBe6>zmp; z0t!il$m8}iyI?7wS#PuCbElWGw11&d; zineC$sx3Dii%m!S(oWyizO@LVmd=XS=GJzxq{-K4G_4m)eQVpAo66U%E(|-1L~YaB zHt@nMQL(PQy{V;Bsf)$y7j(3$--^!mW^q+hOH;eAnOkOI+91=<95%4XkZi_&3SV32y7nef8E9#&Z4cZ$zp=5sse=XS zYw1|s)V{#i=@T{WtqrE)lGf&CR>;!M);5#3w5jv@rA;j;B!!?+UnB{X*0gp=DG@Z& zP|h?!C7hn7&V^b}BK44>#jTA>&va`(ZASVBU%EAa(QPtjdZklyb-?7BX@FBFnp`@e ziyB#^a-v<}Nqb~emIJnd((7C&GqbR@xlvR!w@ZZ9{M%qDNE>`I-`A|RvQDR}gav_) zHc{bgX=rMe&IRk%u3aw>EGbl>xT-yXhT!YyT#WEIk5BbPLF zprDkk+1Qr%m8gzJ#LiNu2`&{C{-%aoq_erTbGA%S!^)1^S9bV)MJtPD&RQ8@3t~D) zv)4(ZA49Mj9y%$gigzWerjDqr$sVfQeLZC zvLujE_CU;GMe92Dk0!ga*>|(HHu|b)Zt}I0XUeN;Bc)ZfH7Gu`(sHCkb{RG8fmT$| z`m5So*R|VSG|NXJ(NcpwuVcedVG`hr@wkin<))A`zy9 zs412Fm>Ci-5=kOKy0-1TcaQVi(Vloun#b+gm*okTX1Rj-Bg0#^qW9Wob7QHh#s*``E}%-{L^PAOS9ZPrSNsYMIVuV>FZ?={fGT#c(l*Y z9hW1QG3`T4OyB63+)0c*9B+Db`ouX%al)t+r+QQvuT)0u*|y)YUtAU3E54m$1asX% zuOV`KgHw#jx$b+i=)NZtzwV80x;MIvjB59$$#iczuX?hP>1RGCY)&Ufx<_HJM)yWd1BYX>%+zhtT#2c^W_PRQ+* zn1(cyjzOxm9&k8DrJOF6cDhvRsl~LJ>7QszcMeOW-fMWP>*}ZAH{IV`?*VVPUY4pa z1MWJXi>2e6M85Al{JK|7FeX*kt&*j>DwX_IDdabd$8TLj5`KFd5{<;_?f&ST#ERbf z{>nI`*B_lXq3rlTv=I%yL-NfuiK&h<;S354+{DQgRi^PqLiLg@b@j1Ee06Vqj1gBo zTpxwsbicda^cOFjW$+>v(LXK^?%>{ydsrixF)okDp)I~r>D;60F1Yv0Xiue{>BUhf z5qGFGE6N*_(DOBsiQ$s}{3lg9c0a)@uF+tBtyztBm2`LSy-s%xHJg0;BhyO5>_(cl}jHIer?YVW*MGQxnwEZZ>EqrnQZJ^H8C{F$b5jUHJH0y^r3%p zC+%BKKaL!6f8ZQN86qKk!OrlCItU$|EOX0P&8plf*Huum3*GRCbbx zUe&?=G|L@)Ijb~Ft!%Q3_%&0Sm8O1OUxR*zSSL%;0W+^ad zwjBCnXlHGue%4_$tc7)$dSSTlo>-mU1wWInoid@iN^Gffl;Fvfq?zHCxPoQ(g5eH+2ejM6UQrC(@Sf_YhhmU= zgy+cFQXxYOK5IN%z5M~YV>Pe$o~Mnc(GOC`UH>)XYj9KMu7A>avU-U>1$A3j|Ag@b z++OhO>USDDq2rV~y+&qNW^Cr9@%f2IzGC!k5c#o#+l@!jyFO?_a-|dz$CJe4K zI<;ShN&Vh?ZpRbR?YYh9Ex&HC)3_CV*uE_GV6IU6s2=RR0cGp#qu1&_=oXCujcivU z|9#m*E4OQKUlx1k_)xv2Lt9}eO5@YPI-}0kV}1Bht>N}xZ@BAmkBQ~RN%YEWWmj5x zoOq;M<}r0}o^ge&0oKM`qqO=Ve|2?YS#SN!>Y}`8^!BNtS;j0p3xhdTf=|gpqd?Xw z%Xk`e_(ZtGSl*M$UH~?8p-~siHx6%L?K$#YgBKc?<0*W8)dfc118$6@rW%=e5@b#k zKXDWVP|#o9^gyeR0*~kh>~V>t>9t>r%Rge5&`Z8pkKO9EZ@-P0LjEBo|j#xPv`b9ee@L{8af2%MNu1 zGJ8rq=@>iomQOiAKg-4P@(lsTx*^c*?=6oVVhEW%NQ>msZ;2H-t`;-h+R6sH4+6x*WX!rE+k>zE~F1P@8VgCB|Wn4`9z$ zjiMCYo^C&$1F3EgYt0=@33;JS4fZKZWxJtdjwih^p=XPm-? z$ON=lwkl_S(qIZK%&S{m5_;(7%QzhK*Z`=DN*zK|U zm+IBrEhE^S#i#8Q9hRr~rfR0fU3_D8`U9#D+K{De^*C&GWR=M4#>nTA;_KMk!Z)pu z*6BiSE6T zddnRLNBrbog77ZUV{20Ep`RGcHcC8Gz#YbXuEgVEx-pMizNKqTxQyLNlZ@Vt6TqEq zan;y7%9G@Ad2)1Z*xf9vc%yD(oYBW#QP$FU%qRKmXTKt^V``*$bnjJ_!57%i%)u-( z-Rbtt^(4=@9M1`d9-HI^XIM{b$ACCm{@GO(e2AI_SG{SITA)|$GjQOF7{{azcC8-vqohZ2b{&-KI)cul39-E zHPTQfis~&79Y{u4G@b{61_HV`N;G)_%yPu@AdpyG8qw3Iqo;RyVywAx zW|GT9eR#x9M;=aiqw()fpS@_lB@x}f?3E3J_|wMzS$`>8Y| z#j>18|7R=B49u&-a}~3HKU=>M?(NUq-n)$3t(1*j3+v9Q93yLC^*Q-Ib1htLvzW+I z{5-W#Rz3f;wRpB#P~-Zsdi%@H(A(#H&|i6xaS?U}F2bCoFhBj!1#(9~JzvKSOf|4O z6wEamu{M=sL}NcH+sMrw4ra<3j2CMslLuUIN9$Scd6?x+1nt#plWCw+vF_y5^6^-A z;tV%>|F+7bau3Y36Vq<&&y~};xlfjgSmJdo;}OevYt<~}NTOUd8#joZqBXI`@TwT3 zz)Yc2ra8BU#u7 zY)eM^xZX|)WWI~d1vmk4)o9QK*^Su+@xKsWfIox z%yLlaIBaQ+l@5Eo2w4jbTfMksskp!yXY`FxFQ^Ht4(&A&Sr)3^Pgf6SSuDQ^DL_eZ z9B-XG^0;@$X}6jiyMu8C*N*Fgw9-?{fn}iU!IGXS|KS=pEh}sh$_9Gd zBW*yfSe+@~VU2T(8|?ws$eKu(_BY&~2K&oGKO=W}<$8CNXWYPeV=BsOoa|>3jX3l( z@v@(Z(d(mQr!8DIhvk~v+3IC18+|nIu(r`hbBCmj4xeJ9z4wf5qctOuHp&%YWyxce z)9LL4J2pBMSRF?yluZnuCSF^2&2}Cud$w3u zR)VxF_pR|(&lZDzH41&EJqG55mkM9WMu*RMxq}+n$BJ*$X3ghEGQwuxej#j_rxVJ!rGfNzwiB_|x{s%F5hhTAA7ZsyH*xYG<*!Z&&+EQSvEko|RDf4W}jFA zl-@HWckCvVnJZkQeVWfX@olp-?9ZL}khWTR{)n?r=3PEbl0F#>?}|20rft+gLoyYRdd zxnjHU4&x-qBzaB>JGJr&+dE}~rw^wQUa0PMy&z9!ynvG#sowYGEc|)>9PSn0Hilf! zN%?b-&(-p$_2{M!p)5xz%f-_O=LC8Up7D4RnjKoRPwqdsC#l#Tht}gVv>niSL+fmp zy{bETW8MwoQA2pewnrB_aJuW~GA&z>;;8&-2fMTGuTEd@ZtKo+cRgqfiGe!0wpKaw zhQt=v0ar#3>7GT=pq~Qm2JPwEyf`-R7h+n*&s|uPj}{XXq7x=!|70Tj#k&@XM_7t? zqTPt?oz;%*$zFky60)S4Vf|_kd)&ZnQsWj&BU@@DhHkAk^W2F1&^N=oQJ?pSk|)?0 zwjVy7UYt0~RbgLm$k9X6x?Huprz}OFCrrgy0b>^Rqy~LR_Kb%>FGM-S<~s&)jwZCw zc-b>S+7{!0rQz%uOa5x4!s$)Zr_4%KUwY3RW4LEFYShd(HB&wD$Z3qshs?vnw|HZ7 z9J%okoakJ2O3u_t&Kb@5$tk{uz!|MG~vTVCKrbfwj%N^3pB(v;Z@+9<(Ejis zZkRKtwgK#=%f0O~Wi8nK>%-2rJ87=A4en87o|A=OUuJzYEMyuiWLkuUOs$eOg0__> z+g2LVL0ipIqdlB8WN(y;-o}F&6nEy;X^!*Ik4(gl{ecz3!iBydt*R*RM=LTslZ-0y zqdMm6Jml-BwtV)as?8(}#KCPoO`>(5#XfM4I%|lkxZHM7l=We+AJ$Y*_LFM7mJ=G0 zHNrDOI3I)E(T9ZFGtQ$*39AWmPf48%SXM2zyF6*I<{wCF9?9Zd1A9txOg%3D5au8p z1LmGF%(PKqK8hJbd6jr5k*#=)P~-9s9(ol0Z3*H|^roS0DJ}A5O5P!hS7?Zbsbi+E z4?5FMNi$REiAW)HIXbUd(q9L{Qf+y3UQ6?Trt>;hNTYK&4k0~`+{Ng2IXa{Z5mNXG z)?bOb7b8CtV%y#a@SI;S`^qv{PxQd;*!jC1J9SZ^+u*tlu3L@aHS1svNd3g+sJoH+ zcC_X?aVzX;gr^4%wt(iD0=YYkJ;TJ}K=lxIc}K7>*B8%LL7ug5$30=Wzsy;kkE1;7 z_`0oKXL4778-0Y_AIrHOcZA2G7riTVx-dO5Ozslb-Ly!D=_#(lXhrQE*WGlL4%4H< zoa>37Vaga2cb~(3S6*;`)|sUAp?8JVC;@YF`8;5s7r=8a;J}`!96x|l>XBt}NF~U9OIU8O8`olY8OZhgN4XreLoed(P$J;QEh*mwfGhI>-wYH$kChxR-ZH~Ze;-X4r`)cEgm%Q}h% zX2Kq3%2Z8~^^qIm?mhPT1DRbo>7etH*>%kCC^%Mce_FqoWuEy~XQ=5$~81t*~<;jFPb zQ5KE!YdqEA-k4^jS*OPoPo1&0pHec{f>>{HC|ieK&9aZud6wHeL(Fuv;hY!8i3I~K z##-ydTr*ar))#;u$}7=7sst)@X63pS@(RdEE%Z9nI+oS)i}#^t+BZJp{>_c*KE1E zdPtrD+~{TrY;nnQxW5YfnvrEwVXdh}9VwG*Y6%1LjCodhCF;|5vk<4b!dHy+6dHv% ztyU(_3ton2Srks6T`He(YIbl5o=(%{>4-XCc?hR*taE62829zA%BebEKdbY`I$JgI zfOWQPGS2#D;pEzRRW9uVXMfLla%~*a<3xHm_cBkzaqh*lsg)) z)@RGTx}IYOrXVFta59o-^fJNaY0OLUY z9J`;~^}#pxfAHYW;0F)wdiq-*Y~Q~9S0Ek=-uI=HG2?*;Eo+!?$=WCWASVuQ{yaLa@jT>dSpDlhTk6`O+MOABTe36YH> zfVhs$lYqBDiT!bsIw2&SJesYr|89kw6r5CACr$iJ(fk|Cq**N+bqqQthaa;hzwK@c{(W!Lm-#I8P&he3?uj*`EQ)hBwKUbp_tvugDT` z1T`lLj=3oXBC4MyjGs8%cO-X7M)t|0;Pwm0iR4h!rq@Ga-WyD}<(H7^)<;v*5asXrvd6+$@vGy7P|$&cC;V=f~3-TfzH@3^^*VX&q` zcYptrla3P~$yiv?p}V6(pE*wcPBD&6xjW=SJdP75`=j1C8A=gTkW5s6)QLYGg`FUl zDTsxP&whLi45WdK{%jHV+QB;Uoqy2dE(?T^A_buc*gL$4 zs0X8xlag+g43DE9jQeAgqen9~CyV$to5rS|#%_&FE|V|JX-8e}+4M#3BSCy@~g#)Z+) z$av%aDc={Nmqg}VpE_`6?qE(I^l?|~Cg>O4{yglb_%~{lt zw7PI>RK|UUTipXcz3&Cb)(3x{@}XmElq1a98kH2QIZ5>mQ7*^*Nf8|1{jqtmd1+gH zJ#QCol{&tSQLn%8`pf3&OnXEK$JjrPRSJ>C<^NrrjauI!*=&;Nd~-x192cRcn4 z9WFR_L?QpK!;S}CQOR@mWcN89%-)oJ=P@|$%iff^c8BYS7uCMdLat=GZVKc z;!h!e3Z{cmFddA7>0rz(SbIH`@l(j3nYhJ*3L)m>zUt})kQa2oyZpubn{dzM4>CqD%=Q$?BG&3A-$COwx zy<`2_PTwkEXS+hb>1uCkp5EEi)hVXa)yS9dr?0|m`P185717YTb}hbEAf_Xd>Aud+ z_Q0xjo%jI4=fAR{%Be=I_A(oIv``ZO^PPiCxYZlCN;dmilp9_|;HZfHX{6M>Skq|X z^129P6se$T)0kN__VAY7CnlZ=)Ii4{S7@&yguFHOPh%4=*i{ny%P%6Hjl%Ac{(l<&9El=s_c%0(W3c&Yf~ zZ8YT`8%_UsLtS60erDKc%4geX`rmA$Dc@$JW%_J1<=?Z>lpnFtl!t6ITeu9Ky3Z_c|4Ac71%eGYuh}4=jMJ$)V(zgQm=sFMu1f3-MbZ!@Cy9FirUl zaQ8$Dk*xi%0?q0%<*VV|f#=~mApH{yZ1TI|=2+=G+)Pgouok!J{~@^Rar2Qw`B#9Q zxJ~&JaHnEW=>;$qRk^f%$Y5doU=y`cXLn)OHhH$cyX{dqJ!4BEUH z{%=8F3waX!Q2$R6awhbxsc2)+r92U|dC~vG2-*YsM%b$vKikb?HhOA=ei7)OK)x06 zGW>r4?SsAe5jN>Xpx**L7ilDYLxlg;pkpwedl5+aZ4vT~5%hzgUqK^(PRF-1LjGg~ z{jCW4r3m`X2>L(-9ReLd<7h;jOy92~Hj*=H-a|9 zzY+8+HhB~1LpJ%XpyznQ{_g~R9q7$E{s*XUlm8>=KY}*Xw+pl{C+z>5pzj1-tNni$ z^q@`tI_TekUZmx3gPxNc_W!>?UkBRs{~qXn0`1cJzXJU_=!Kg81L%aju>Ajk&au&n z=m_S3UZ(ZaK|cg~hNj)1{|9KZ{LTmco=v}i{-=iJrJ%0^Jx%+s1bq+axthKf^edo~ zH2nq8{|EF%Xfw2@RiMp_?Xem3`FK8a4oCT|5%O-(Z{hjuaw_>|&{UZQefCFNBj`sW z=-vo=7wGpcMHo81e**mhp5HwPlkx8dz4kJUA+`L+ps&O8c&C;Ne2Hv&gP7VVrgnmkUs@ju41WT%W?g3ozS|jS5c8K-%wC2sV45Gr zT)9%N)2&<=Xbjx;c|Vb9dXj!3zn5tViyDRLZY&CH82us5j$7M1Epeb|wdG!I_qKLj zvn6QsHHHIRO^N+uoDm;I{QI{#X$61vZ*$^XpGzCsoA{Yfex(y;)}YL+^8dl_b;{>c z;@5<@5B(nTyBd#c+=>3t`52y4=$DB{HBOBJjY0b~;&zNviIA5A6aNX%ZQ?hD*hqX% zh%FkoYuvAqoqXcAgt(dreLoTUZ5q2YKBbZUbmDFyhKOGm;-|!?g%~D&1J5Tsf1J+? zQAXT>JqY5%c#aa0-bKWJM1F{vEG#1;-Twhh{Ac*X9D?|W#*Z~}Esy^DiM^Oh6ZK~ zSFzTi>7&HQvG$_rW5g%$9K*OSaj#lKWPC4zW_+9wkv~b}6ym>PDouP@h*`uJu@(iS zej^e7H*7D6-zE$&g5)tonTK*yt`TUTG^!=8I z@INC$Z&JGAPbDJ$X++595)pr`mao$CHCnzw%eQNJujW5XM7S?&`H+?mYx#d@`Ef0e zodA8LZw3+Rn@dFei--uPQS+NM{|?RHN<{j0Yx%zrk^Yy7@c%PRU*RqF%jW>sQG^&B7G;c zJn1~pNdHtK{1p))FCoHzwU)2a@->>jfrxOoX!%oG{;Zb2tmQw{@}Cls{)v--|BQJK zkm;`_B0tNBu;a~?BOP0bh<_&$@w}k<`!)Y<%|Aj!`v0Ki&dH#W{zM}DyNQq&5fN^g zmM_%uWm?{*oP$J!|1lAIoJf!#PXymZ1pgu;;xE(ktBFY8 z^+f2c*7Ccwe5;l}qUF1_e7}}|PxId)BK%)y`BCDFXtxL^%722r zxkG#y{)tbbA13Zndoh%|vOq(hdoSeg(ew*M=yT77a_+4V3y9!zFNO3AMEHAA)7&E= zpL-$X&n1H9-UpF;9K?4t7I+msgNSfzH2o-$`FmT_16uwLahKYQkm2SidIb^Ta*u)d zwnpw5kmlY1k$V8d-5R;3Pg>*wQ6AC6CowP9^bC!4K&FRl@YL%eLT@V(>DjOO{hEJ7 z(=(<*&UiI)jhz0u7EYXUKEnMF_NlR)_z~7diC+_7G5!L@zkv8L(nEYo zh{rX*U*kcI$BEFZzfkKF8NSBnG`^~FK;!!w|DZAUBIVCZgdNV-$hCXsXBiRsT|xXJ z+Bp&9Ge2=F#tFnPVZ2BDGU|)?0QL@uTTs5l801IeR*l<;_Y3hRkm>%6_%ZY^RyagN zIekj}CF=7M=p#MxMEFZ0B3&-xgQ#EPHndkF(+6a@uWI~-#$y`e^OfAAu~y^b8jnna z{M$ktC+LCE?i{s-)a_-nLN;;+z7iN8TRB_h3V6VZOJn2vCe zzTFzRSHW-wi17Cg5&n)45pIZxa2H$#fBncGkovO=70x9-3ONz+{95x-a>99sTIX@z zB_Auo8C2_l&W&n)+PN9eP3qmJ*6^J@sMo+M>offPocr0n#sV;1W%si*?gYkPv-e^N1ZPTI3()uojdhiws^^R`{Fen ztC4=JbKyyjvU=DWzdfqz!~CWwwSHi|;}PYF8YD;LT@Z@0ab2358S3_Dc5U!GiZ;}% z*r^@%H4b0sUD>t~ycZ|(Ka@TldGF&mN9r^8MRc77wlqil9aivRre1DK{#^`eGmZ69Bm?lz8)kiW_W9c(4m0I&#$!7V7 zOUY@anA&C;pQ;yrcV@KSPUO9`ek9A)wl6EAtrYJ7mwLL8t~m9^4&LKoO5=;=_b;Ri z?;UsbN*BHjjdzggqgC2|dWf#fu9)Hye;O=4zG$$v6joJ=5^6;WwOV%A3Onr5cK8d} zA!Cd|j2U=yNV)0z0KRe=U!=b3$W(_@mYGb6`Sud)(_?*qBe-`D-sLGlp4d+DtzrDq zw|Vb3CgL5}Nq7fP$ae}=$kU3=FAF*bgLz+iuhcUQY0ATQBJat&57c+%cOfSrhu=k; zDe-()zM(Y7Gp+D}6(yb;<`fc>&oZH2cK(NWd!O%SW+vfvg6-#dop`TKy;XZ^yc_eb zmGLfzRX7GVUU8dL|51$aJyoFjj9#pR~@?rA4(JmHLIc?VOt863;^2c0R9+K3G=vwxddm zZ6{n>>&}=u)ppF(skSqA3RK$}TV}Q$Q>xmI8LDbKrcAXDQ>NO^*fQ02>@v0;)2Hfb z>{2B&+m6y>4YBQ<*Q*}#8!;|QA zHj$0DkX8M8@s$I!=aX-adY0q6R`2Gg4T`)}d<$Sa?s2#iaL3_}!ELtL{z^3ln5J7? zL19txjG418pFL-OdBuV&E5o#JRYPObYU%H9<2yXd zWxVI$Mp$j8U@`PeKjfL=A=%Wkt~;SuWl>>0>LYvBwQM}rW57rN2g|iGzo|gd_VD7t ztT7{l%;p3YzU=&SKl2@Jok>$6M#=MN_Rx`BdHz8098x~pQgBHBbFD-ud6|u-|IId< zdEI8CDL)o#2B`dFDyT0NzWt0f{l8$@l@*ZGAL|S|%a~UVZl1xyQkE=B=7DDj>^8u# zOL5Z%%rjG0!#y9-)Bve}Bhb94?>7k`>2}-?K_AmCsxw{*e$mDk`u6>4Wy%PIeUu&StH zCH^fQw%er({|>KweP@#-b|He}Ot5Dm2A*2tSS-8#eVJctkgQx%MKQdII zFJ0f#FvkBLH2-O7#Ku0hmP8`S|5GjhPc1*8X?CjgA5CO_ ziP+Z}B4VBY7;!T8u80?+aPeSC#DgZ4h=DU9B>EJ)l)c>;4%j;}weTBuJf35Eq zupL}uto3!(cjLcJaaN$_E#dEUs&ya!Uyu#;fA+uZ@AijR8kDZN>cTZ5t{ZmM&#B+w zFSY*n!RQc!d%p`E6<(=lqBYxjCwC}gLcRR;i~Oho<+>y^$1}0;xPPB5)+o=|x)Vbs zo{2@>R=lUv6CstNS=QX_Z{)qgzxp^ZTGhWa0yGPGp~;RK2PUDN6o3bF#Z%|>ZvR(GjSf;2P+Z82Z1-edI z2Ix}dIKf_q%tsmS9Nd@S<~ZU8pm|Zg2KQpz=<1|=6VSXUe;D_zxVPh`fBA&Oe;Z!k z*4b+QvtN!V#`;IU0shS_zds^!} zjqj`-&T#wV@`mR>t@E6o7wQ$p-ZTw3;2M2Ps-UP-Yn%%NqwbzDO(ohSdH?0hR94~QQv8*)9Ra^fF!O*Qt& z5D&Oi8lC>_Vz9>a=_uBvQE%p8UcNZE_9Ix2E{jZj2hFV2+#>j0mS%-$@)@F8{-{@- z1GD_&^51r{gv-vOW+0E|7L~6Z%z%*f7QxGhJU{-#^>J zc;52A-0v>?rp@0omZZ-=uB@(Xw= z;3>-@v=sk!tl3cI@9-;&2w0)o`3GFRI=q!uc)fuYR-D7W8!Ufyf$J@PuWzZvcL!=L zew}Zz#UJ+fTImY63b*gda7_Mk%japrI~ivI~w4E@6guT(C>c+r6`!}V9PJ$TWfvu&9Bq8vYqoM+@-naCTd9~Z)x(Aj>M zb^DL&G>jnpk@^vTT>jB_)qi$X;UOsbZ9Q{bJmO#OFT+=4M|{WepBNu57l$Tz_Tg)Q z%l+74L_hJee_tRx3Lo*;VN`y=H7`FF|GAECeu1&BekRI_`rQBH*Y(~!u>t-LxVtgd z?@Q?RF_a=?H#T($4|NAEurK{G4A;WwCPnRrH>$pEXIXyNlxeHSb4-?kh`~1!O+JE0Nx8#r4eEsev$=7c6$Mk*k(5CE+e-AC+ zaoLvghZbCZ>;D|--~08$dw;q7->#qYN!lkj?A|zU`%iB2d~?UMaR(jCH>JONZ{gH8 z?o7I_^Tt=(Kl|sO1-}t{q_6XnzSmz5^!?(#t6u%xn_qoBCVh)4s$tw@rWR-|o40TKo1VKYr~gW3~I4wl5n0_O)x9zn}5( z_Q9#KkNx!CnaO`>+qEWj((Ai3;+rp@vgr1O7w+A^XU2DuJaej_J$UssKis+e_pQ_Y zzuov?XKTaPyC!!1U~|0l`&*Bne0AHenrn9d>1%&}_0z6f-~8K~1OD~CD>DQAO&cdW z`a0cQaAC4~XO43t&P1q3Z&(hIv^hW8Z3_z`DI-SC1y83}p#3=M2^aOewyBSqK91$d zrarIlAz}9U4rRRO<3`%r0P^}H^h`fwP={CKobh~&)2~$``D^MC&9qTafcXN~&N-~d z(#>h-jQyBz+)oesGQ%@z6Yc!JWX{NZgfEAD51e8C0MkV$a(e;X&sZ67$b56}LtRR~ z-8OU`1Wjh{=f$REx-$bYk+yc05BVfuhEug0&fOR2CfE90OGr}F+=gA$zK5eC6Yhgn6CIS9UFpj-hQIpFZ_avf z7vNridl~L#+(F#&(U9RTz`X$XGTgApG66Kly>qZqF;c(5zZtQx<~IRZ^BaMz`Fnt@ z`5=%re>adde;1H7eU-AERiITPJ^eKz zz2*W(TZB4Q8#O?5L|C1Y#SXAma2mRTJy~2xQQ^KVoQwX-b1l>G{>=#ftK4yaG18Ym zaNJ)6ybxFj%mWqxvw`fnGJ(^9lYuO!2|$)p3XtVA4k&vvAj>HV$Z{H;?|uGc{J)9l z!F_C{1NL^v^P1e_A)ZnqQWiTf0=wGhcUJ)GV=#NN|T1?Qsf|B{WFcCf*pjTF-Y zrT}RHSwLC<`&U{(CXhXr8%PVt0MY_nKw1F%TUr3WyH5)^4@e7`2pnA!oGH7uLAO!UICm9oCmxdSPGm4yc{?aSPbMd{xYCyIU97#*`Qm_2HkShGoSXNT8`>r zXfLYes2+y)qFRpXVQ4R>wj5b6F%!z726Bx||Gs)>C`aNx{{}z*8wYKG?@mPF_H-^Efm>i^H@{)>4o%*1;7g&Znh+8;t zJ8?(j#wjTM>^IvF`lyu5IHo@tPm<_C^tutPJe-SIV*{QP&QOfRaBqg4x8H@s-7NQx z%^dyRzW;9D|6j82zrFRPzs_0HsaW$cFZ4a~iacYm4Tqa^h4xDy+Y-bzm)NgJY({|G#U!XulPxS|9p@jmA=haG8~f(qK8% z*l5a|tz{e~-)W;MzXNL*>QeIOY&7LFu%=;`H`-{*A7SCiOZoq`ji!9I+GB@H$rspY z$~&=Ur!FOb+eTCFvTV)DxKtnO%mvSAP>W^6^`l&=seV|mm*M^+WGhhTlylwkT9j8U zkn~l+uY*3O>1%*rMR}#_@K%8S7Ru*EE$;v}p*(tYc=v+-4f4NC%XvoQO61p+e+~4% zBY&nmVnIl*Z(%iS!Q%NV7c^DzkcO|Lqp7`fWt*?vw^s5cmkLWe+t)R8T4cpq<*%x? zqP1mp;AW|ePyAG@Yj0nGZ=zSUu50ORYB$-H&Ayv)=Cc#uif3RI%}u^`@=SSEZKSlS zwgx9d@wNAIBnwv?Zk`WZgS->()3{q>zeafu5%PF6Q0npf)5IE$JsO|U=tg-{K1*Xd z*VaH!)3{Kh2jx!wB9u2V9pxv*s3(s|*}z_DfeXT)U(z0WPcsU?d+cr5xXno|$k&7E_g2!FfB+{OSG3 z--r<2wvO4h_kKAhk53E zk~3^#WGyLK+(4p{P@NXw8>@*GZeLs|)`+Q25BxbRq3f-R#4@)pY!Nao`fMlXm`j9^!XItEiwaQ;%p* zI{z0y8<>2AGYpnXDsIxMtAhjAF7&~7DX083!?UqY;r}J$A(ngiatIt36nqA&%OUHf z(Ik<3%I~leqvV@yH04KZG{fh&G1aB~H(Ldw{I}U?`rmJ(O`pWE#v|O4Vem{N#}^j@ z&5Pwa19uZ{FO(?10&aej*wkMF`j?=4fRwKW-ir8ZG%e)A%^Wt!Z$8$v2U^<$o$If{ zu34KN3XB>=NG&;R80#C6inqR_vuW+38tr}Q`i|N_!!0W-78&Y4yl6h&T|hb#F=yDO c@oA0wH9m{9Q!d|~0J@QO((>I0;8solU*xH)9RL6T literal 0 HcmV?d00001 diff --git a/libdso150.h b/libdso150.h new file mode 100644 index 0000000..1942595 --- /dev/null +++ b/libdso150.h @@ -0,0 +1,244 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Filename: libdso138.h +// Version: +// Data: +// +// Author: Liu, Zemin +// Company: JYE Tech Ltd. +// Web: www.jyetech.com +// +//----------------------------------------------------------------------------- +// +// Target: STM32F103C8 +// Tool chain: CodeSourcery G++ +// +//----------------------------------------------------------------------------- +// Required files: +// +//----------------------------------------------------------------------------- +// Notes: +// +// +//----------------------------------------------------------------------------- +// Revision History: +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef libdso150_h + +#define libdso150_h + +//#include "Common.h" +#include "Screen.h" + +// ======================================================= +#define SampleBufSizeMax 0x400 + +#define VPosMax 500 +#define VPosMin -500 + +#define VSenMax VS_5mV +#define VSenMin VS_20V + +#define CplMax CP_GND +#define CplMin CP_DC + +#define TBMax TB_10us +#define TBMin TB_500s + +#define TrigModeMax TM_Single +#define TrigModeMin TM_Auto + +#define TrigEdgeMax TE_Rising +#define TrigEdgeMin TE_Falling + +#define TrigLvlMax 1200 +#define TrigLvlMin -1200 + +#define TrigPosMax SampleBufSizeMax +#define TrigPosMin 0 + +#define TrigSenMax 100 +#define TrigSenMin 0 + +#define RecLenMax SampleBufSizeMax +#define RecLenMin 512 + +#define SampleMidValue 0x800 // For 1.65V bias +#define WWindowMidValue (SampleMidValue >> 2) + +// ======================================================= +// Scope control type definitions +// ======================================================= +// + +// -- Time base type +enum TimeBase { +// TB_min, + TB_Custom = 0, + TB_500s, + TB_200s, + TB_100s, + TB_50s, + TB_20s, + TB_10s, + TB_5s, + TB_2s, + TB_1s, + TB_05s, + TB_02s, + TB_01s, + TB_50ms, + TB_20ms, + TB_10ms, + TB_5ms, + TB_2ms, + TB_1ms, + TB_05ms, + TB_02ms, + TB_01ms, + TB_50us, + TB_20us, + TB_10us, + TB_5us, + TB_2us, + TB_1us, + TB_05us, + TB_02us, + TB_01us, + TB_50ns, + TB_20ns, + TB_10ns, +// TB_max + }; + +// -- Trig Mode type +enum TrigMode { + TM_Auto, + TM_Normal, + TM_Single, + TM_Max + }; + + +// -- Trig Edge type +enum TrigEdge { + TE_Falling, + TE_Rising, + }; + +// -- V sensitivity type +typedef enum { + VS_UnCal = 0, + VS_50V, + VS_20V, + VS_10V, + VS_5V, + VS_2V, + VS_1V, + VS_05V, + VS_02V, + VS_01V, + VS_50mV, + VS_20mV, + VS_10mV, + VS_5mV, + VS_Last + }TY_VSen ; + +// -- Coupling type +enum Couple{ + CP_DC, + CP_AC, + CP_GND + }; + +enum FocusType { + FC_VSen = 0, + FC_Timebase, + FC_TrigMode, + FC_TrigEdge, + FC_TrigLvl, + FC_HPos, + FC_VPos, + FC_Max + +}; + + +enum DsoStatus { + DSO_CaptureDone = 0x0001, + DSO_Trigged = 0x0002, + DSO_Hold = 0x0004, + DSO_Rolling = 0x0008, + DSO_NormalDisplay = 0x0080, +}; + +enum DispUpdateFlags { + Disp_Panel = 0x0001, + Disp_Param = 0x0002, + Disp_Trace = 0x0004, + Disp_None = 0x0008, + Disp_TrState = 0x0010, // Display trigger state +}; + +// ===================================== +// Exported variables +// +extern U16 *SampleBuf; +extern U16 *CurrentSample; +extern const U8 LibVersion[]; + +extern FONT JYELogo; +extern FONT Jinyuedianzi; +extern FONT Jyetech; +extern FONT Web; +extern FONT ByJyetech; + +// -- Function Prototypes -- +void DSO_Init(void); +void StartCapture(void); +void StopCapture(void); +U16 GetDsoStatus(void); +void SetHold(void); +void ClrHold(void); +void UpdateTimebase(void); +void Rolling(void); + +S8 SetVSen(S8 vsen); +S8 SetCpl(S8 cpl); +S16 SetVPos(S16 vpos); +S8 SetTimeBase(S8 timebase); +S16 SetHPos(S16 hpos); +S8 SetTrigMode(S8 trigmode); +S8 SetTrigEdge(S8 trigslope); +S16 SetTrigLvl(S16 triglvl); +S16 SetTrigPos(S16 trigpos); +S16 SetTrigSen(S16 trigsen); +U16 SetRecLen(U16 reclen); +S16 SetVPosOfs(S16 ofs); + +S8 GetVSen(void); +S8 GetCpl(void); +S16 GetVPos(void); +S8 GetTimebase(void); +S16 GetHPos(void); +S8 GetTrigMode(void); +S8 GetTrigEdge(void); +S16 GetTrigLvl(void); +S16 GetTrigPos(void); +S16 GetTrigSen(void); +U16 GetRecLen(void); +S16 GetVPosOfs(void); + +void DsoDisplay(void); +void UpdateDisp(U16 disp); +void CancelDisp(U16 disp); +U8 SetFocus(U8 focus); +U8 GetFocus(void); + +S16 GetAverage(void); + +#endif + diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..3350ac2 --- /dev/null +++ b/readme.txt @@ -0,0 +1,76 @@ +================================= +DSO Shell (DSO150) Source Codes +Ver: 113-15011-060 + +(C) JYE Tech Ltd. All right reserved + +Web: www.jyetech.com +Forum: www.jyetech.com/forum +Email: jyetek@gmail.com +================================= + +1. Contents +----------- +Files contained in this package include: + + 1 ) 113-15011.c -- The main program + 2 ) Board.c -- Functions for initialization and lower level operation + 3 ) Board.h -- Header file + 4 ) Command.c -- Functions for key command analysis and execution + 5 ) Command.h -- Header file + 6 ) Common.c -- Basic type definitions and general functions + 7 ) Common.h -- Header file + 8 ) Eeprom.c -- Emulation of EEPROM + 9 ) Eeprom.h -- Header file +10 ) stm32f103_it.c -- Interrupt handlers +11 ) stm32f103_it.h -- Header file +12 ) Screen.c -- Functions for screen related operations +13 ) Screen.h -- Header file +14 ) libdso150.a -- Library of DSO150 core +15 ) libdso150.h -- Header file +16 ) stm32f10x_conf.h -- Configuration file +17 ) startup_stm32f10x_md.S -- Start-up file +18 ) makefile -- Makefile for building the project +19 ) STM32F10x_64k_20k_flash.ld -- Linker script +20 ) readme.txt -- This file. +21 ) Libraries(folder) -- Libraries for STM32F10x MCUs + +2. How To Build +--------------- +The project was developped under CodeSourcery G++ Lite. Under Windows environment please follow the steps below to build the project: + +1 ) Download Code Sourcery G++ Lite from http://www.mentor.com/. Install it and have environment variables setup properly as instructed in the accompanied documents. +2 ) Unzip all files in this package to a folder. +3 ) Open a command line window under Windows. Switch to the folder that contains the unzipped files with "CD" commands. Type and execute "cs-make" from the folder. + + +3. Support +---------- +There is no technical support for questions related to the source codes. However, users are welcome to present their questions to and seek helps in JYE Tech Forum (http://www.jyetech.com/forum). + + +4. Limitations +---------- +The library libdso150.a only runs on DSO Shell or equivalent boards. It may not run on other boards. + + +5. License +---------- +DSO Shell source codes are free software and open for education, research, and +commercial developments under license policy of the following terms. + +Copyright (C)2017 JYE Tech Ltd., All right reserved + +1 ) DSO Shell source codes are free software and there is NO WARRANTY. +2 ) You can use, modify, and redistribute it for personal, non-profit, or commercial product UNDER YOUR OWN RESPONSIBILITY. +3 ) Redistributions of source codes must retain the above copyright notice. + + + +6. Revision History +------------------- + +Version Date Summary +-------------------------------- +0.60 2017.05.10 First release. + diff --git a/startup_stm32f10x_md.S b/startup_stm32f10x_md.S new file mode 100644 index 0000000..2d689a5 --- /dev/null +++ b/startup_stm32f10x_md.S @@ -0,0 +1,357 @@ +/** + ****************************************************************************** + * @file startup_stm32f10x_md.s + * @author MCD Application Team + * @version V3.3.0 + * @date 04/16/2010 + * @brief STM32F10x Medium Density Devices vector table for RIDE7 toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Configure the clock system + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M3 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ******************************************************************************* + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2010 STMicroelectronics

+ */ + + .syntax unified + .cpu cortex-m3 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss + +.equ BootRAM, 0xF108F85F +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + .word WWDG_IRQHandler + .word PVD_IRQHandler + .word TAMPER_IRQHandler + .word RTC_IRQHandler + .word FLASH_IRQHandler + .word RCC_IRQHandler + .word EXTI0_IRQHandler + .word EXTI1_IRQHandler + .word EXTI2_IRQHandler + .word EXTI3_IRQHandler + .word EXTI4_IRQHandler + .word DMA1_Channel1_IRQHandler + .word DMA1_Channel2_IRQHandler + .word DMA1_Channel3_IRQHandler + .word DMA1_Channel4_IRQHandler + .word DMA1_Channel5_IRQHandler + .word DMA1_Channel6_IRQHandler + .word DMA1_Channel7_IRQHandler + .word ADC1_2_IRQHandler + .word USB_HP_CAN1_TX_IRQHandler + .word USB_LP_CAN1_RX0_IRQHandler + .word CAN1_RX1_IRQHandler + .word CAN1_SCE_IRQHandler + .word EXTI9_5_IRQHandler + .word TIM1_BRK_IRQHandler + .word TIM1_UP_IRQHandler + .word TIM1_TRG_COM_IRQHandler + .word TIM1_CC_IRQHandler + .word TIM2_IRQHandler + .word TIM3_IRQHandler + .word TIM4_IRQHandler + .word I2C1_EV_IRQHandler + .word I2C1_ER_IRQHandler + .word I2C2_EV_IRQHandler + .word I2C2_ER_IRQHandler + .word SPI1_IRQHandler + .word SPI2_IRQHandler + .word USART1_IRQHandler + .word USART2_IRQHandler + .word USART3_IRQHandler + .word EXTI15_10_IRQHandler + .word RTCAlarm_IRQHandler + .word USBWakeUp_IRQHandler + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word BootRAM /* @0x108. This is for boot in RAM mode for + STM32F10x Medium Density devices. */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMPER_IRQHandler + .thumb_set TAMPER_IRQHandler,Default_Handler + + .weak RTC_IRQHandler + .thumb_set RTC_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Channel1_IRQHandler + .thumb_set DMA1_Channel1_IRQHandler,Default_Handler + + .weak DMA1_Channel2_IRQHandler + .thumb_set DMA1_Channel2_IRQHandler,Default_Handler + + .weak DMA1_Channel3_IRQHandler + .thumb_set DMA1_Channel3_IRQHandler,Default_Handler + + .weak DMA1_Channel4_IRQHandler + .thumb_set DMA1_Channel4_IRQHandler,Default_Handler + + .weak DMA1_Channel5_IRQHandler + .thumb_set DMA1_Channel5_IRQHandler,Default_Handler + + .weak DMA1_Channel6_IRQHandler + .thumb_set DMA1_Channel6_IRQHandler,Default_Handler + + .weak DMA1_Channel7_IRQHandler + .thumb_set DMA1_Channel7_IRQHandler,Default_Handler + + .weak ADC1_2_IRQHandler + .thumb_set ADC1_2_IRQHandler,Default_Handler + + .weak USB_HP_CAN1_TX_IRQHandler + .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler + + .weak USB_LP_CAN1_RX0_IRQHandler + .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTCAlarm_IRQHandler + .thumb_set RTCAlarm_IRQHandler,Default_Handler + + .weak USBWakeUp_IRQHandler + .thumb_set USBWakeUp_IRQHandler,Default_Handler + +/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/stm32f10x_conf.h b/stm32f10x_conf.h new file mode 100644 index 0000000..627579d --- /dev/null +++ b/stm32f10x_conf.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * @file FSMC/SRAM/stm32f10x_conf.h + * @author MCD Application Team + * @version V3.3.0 + * @date 04/16/2010 + * @brief Library configuration file. + ****************************************************************************** + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2010 STMicroelectronics

+ */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CONF_H +#define __STM32F10x_CONF_H + +/* Includes ------------------------------------------------------------------*/ +/* Uncomment the line below to enable peripheral header file inclusion */ +/* #include "stm32f10x_adc.h" */ +/* #include "stm32f10x_bkp.h" */ +/* #include "stm32f10x_can.h" */ +/* #include "stm32f10x_cec.h" */ +/* #include "stm32f10x_crc.h" */ +/* #include "stm32f10x_dac.h" */ +/* #include "stm32f10x_dbgmcu.h" */ +/* #include "stm32f10x_dma.h" */ +//#include "stm32f10x_exti.h" +#include "stm32f10x_flash.h" +#include "stm32f10x_fsmc.h" +#include "stm32f10x_gpio.h" +/* #include "stm32f10x_i2c.h" */ +/* #include "stm32f10x_iwdg.h" */ +/* #include "stm32f10x_pwr.h" */ +#include "stm32f10x_rcc.h" +/* #include "stm32f10x_rtc.h" */ +/* #include "stm32f10x_sdio.h" */ +#include "stm32f10x_spi.h" +#include "stm32f10x_tim.h" +#include "stm32f10x_usart.h" +/* #include "stm32f10x_wwdg.h" */ +#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +#define USE_FULL_ASSERT 1 + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +// void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM32F10x_CONF_H */ + +/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/stm32f10x_it.c b/stm32f10x_it.c new file mode 100644 index 0000000..e6fcc6e --- /dev/null +++ b/stm32f10x_it.c @@ -0,0 +1,184 @@ +/** + ****************************************************************************** + * @file FSMC/SRAM/stm32f10x_it.c + * @author MCD Application Team + * @version V3.3.0 + * @date 04/16/2010 + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and + * peripherals interrupt service routine. + ****************************************************************************** + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2010 STMicroelectronics

+ */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_it.h" + +#include "Common.h" +#include "Board.h" +#include "Command.h" +#include "libdso150.h" +//#include "FSM.h" + +/** @addtogroup STM32F10x_StdPeriph_Examples + * @{ + */ + +/** @addtogroup FSMC_SRAM + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M3 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSV_Handler exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ + + // Key scan + if(--TimerKeyScan == 0) { + TimerKeyScan = 2; // 2ms + BitSet(Keypad.Flags, (1 << KF_DoKeyScan)); + } + + // General timer + if(GTimer) { + GTimer--; + if(GTimer == 0) { + GTimeout = 1; + } + } +} + +void USART1_IRQHandler(void) +{ + +} + + +/******************************************************************************/ +/* STM32F10x Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f10x_xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles PPP interrupt request. + * @param None + * @retval None + */ +/*void PPP_IRQHandler(void) +{ +}*/ + +/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/stm32f10x_it.h b/stm32f10x_it.h new file mode 100644 index 0000000..b039431 --- /dev/null +++ b/stm32f10x_it.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * @file FSMC/SRAM/stm32f10x_it.h + * @author MCD Application Team + * @version V3.3.0 + * @date 04/16/2010 + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @copy + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2010 STMicroelectronics

+ */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_IT_H +#define __STM32F10x_IT_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +void TIM3_IRQHandler(void); +void USART1_IRQHandler(void); + + +#endif /* __STM32F10x_IT_H */ + +/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/