⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svctest.c

📁 STM32 开发板例子:SVC. 开发环境:Keil For ARM
💻 C
字号:
/*

                         \\\|///
                       \\  - -  //
                        (  @ @  )
+---------------------oOOo-(_)-oOOo-------------------------+
|                 智林STM32开发板试验程序                   |
|                  Timer1 定时器中断实验                    |
|                 刘笑然 by Xiaoran Liu                     |
|                        2008.4.16                          |
|                                                           |
|           智林测控技术研究所 ZERO research group          |
|                      www.the0.net                         |
|                             Oooo                          |
+-----------------------oooO--(   )-------------------------+
                       (   )   ) /
                        \ (   (_/
                         \_)     

*/
/*----------------------------------------------------------*\
 |  引入相关芯片的头文件                                    |
\*----------------------------------------------------------*/
#include <stdio.h>
#include <stm32f10x_lib.h>    // STM32F10x Library Definitions
#include "STM32_Init.h"       // STM32 Initialization
#include "TFT018.h"

/*----------------------------------------------------------------------------
  Note:
  Software Interrupt Function accept up to four parameters
  and run in Supervisor Mode (Interrupt protected)
 *----------------------------------------------------------------------------*/

int __svc(0) add (int i1, int i2);
int __SVC_0      (int i1, int i2) {
  return (i1 + i2);
}

int __svc(1) mul4(int i);
int __SVC_1      (int i) {
  return (i << 2);
}

int __svc(2) div (int i1, int i2);
int __SVC_2      (int i1, int i2) {
  return (i1 / i2);
}

int __svc(3) mod (int i1, int i2);
int __SVC_3      (int i1, int i2) {
  return (i1 % i2);
}

int res;
char s[30];
/*----------------------------------------------------------------------------
  Test Function 
 *----------------------------------------------------------------------------*/
void test_t (void) {
  res  = div (res, 10);                           // Call SWI Functions
  sprintf(s,"div:%d",res);
  LCD_PutString(10,80,s,Magenta,Blue);

  res  = mod (res,  3);
  sprintf(s,"mod:%d",res);
  LCD_PutString(90,80,s,Magenta,Blue);
}


/*----------------------------------------------------------------------------
  Test Function 
 *----------------------------------------------------------------------------*/
void test_a (void) {
  res  = add (74,  27);                           // Call SWI Functions
  sprintf(s,"add:%d",res);
  LCD_PutString(10,60,s,Magenta,Blue);

  res += mul4(res);
  sprintf(s,"mul4:%d",res);
  LCD_PutString(90,60,s,Magenta,Blue);
}


/*----------------------------------------------------------*\
 | MIAN ENTRY                                               |
\*----------------------------------------------------------*/
int main (void) {
  stm32_Init ();                                // STM32 setup
  LCD_Init();
  LCD_Clear_Screen(Blue);

  Font = 0;
  LCD_PutString(30,0,"STM32F 开发板",Cyan,Blue);
  LCD_PutString(30,16,"软件中断实验",Red,Yellow);
  Font = 1;
  LCD_PutString(38,32,"Version 1.0",Green,Blue);
  Font = 0;
  LCD_PutString(10,94,"智林测控技术研究所",Yellow,Blue);
  LCD_PutString(36,111,"www.the0.net",Magenta,Blue);

  sprintf(s,"res:%d",res);
  LCD_PutString(20,40,s,Magenta,Blue);

  test_a();
  test_t();

  for(;;) {
  	}
  }
/*----------------------------------------------------------*\
 | END OF FILE                                              |
\*----------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -