找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1348|回复: 7
打印 上一主题 下一主题
收起左侧

ARDUINO STM32离线安装包

[复制链接]
跳转到指定楼层
楼主
ID:328023 发表于 2023-8-2 11:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
安装arduino2.00以上版本后,运行一次,把这个文件放在C:\Users\Administrator\AppData\Local下,就可以驱动STM32F030 STM32F103系列单片机,开发效率远高于keill,

下载路径:链接:https://pan.baidu.com/s/1eT9Zsy11HqAp5Yr37yRqKg
提取码:lfs5
b230802



#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3)  ||defined(STM32F4) || defined(STM32F7) || \
       defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7)  ||defined(STM32G0) || defined(STM32G4) || \
       defined(STM32WB) || defined(STM32MP1) )
  #error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
#endif




#define TIMER_INTERRUPT_DEBUG         0
#define _TIMERINTERRUPT_LOGLEVEL_     0

#include "STM32TimerInterrupt.h"


  #define bpm1_h       digitalWrite(PA15, HIGH);              // Pin 33/PB0 control on-board LED_GREEN on F767ZI
  #define bpm1_l       digitalWrite(PA15, LOW);

  #define bpm2_h       digitalWrite(PB3, HIGH);              // Pin 33/PB0 control on-board LED_GREEN on F767ZI
  #define bpm2_l       digitalWrite(PB3, LOW);
   



#ifndef LED_BUILTIN
  #define LED_BUILTIN       PB5              // Pin 33/PB0 control on-board LED_GREEN on F767ZI
#endif

#ifndef LED_BLUE
  #define LED_BLUE          PC13               // Pin 73/PB7 control on-board LED_BLUE on F767ZI
#endif

#ifndef LED_RED
  #define LED_RED           PB5             // Pin 74/PB14 control on-board LED_BLUE on F767ZI
#endif
   
#include "STM32TimerInterrupt.h"
#include "STM32_ISR_Timer.h"

#define TIMER_INTERVAL_MS         10
#define HW_TIMER_INTERVAL_MS      10

void sub9(void) ;
#define        u8      unsigned char
u8 Rxdata[10] ;
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete
boolean bfbase4ms = false; ;
boolean bfdatasend = false ;
int inByte;                     // Byte read from Serial1
unsigned int wcad ;
  union{
    struct{
        unsigned    bfbase        :    1    ;
        unsigned    syi893        :    1    ;   
        unsigned    bfpoweroff        :    1    ;
      
         unsigned     shu164 :1;

        unsigned     bfrf_isrread    :    1 ;
        
               
        }onebit    ;
        unsigned    char    allbits    ;
    }wflag    ;

// Depending on the board, you can select STM32 Hardware Timer from TIM1-TIM22
// For example, F767ZI can select Timer from TIM1-TIM14
// If you select a Timer not correctly, you'll get a message from ci[ompiler
// 'TIMxx' was not declared in this scope; did you mean 'TIMyy'?

// Init STM32 timer TIM1
STM32Timer ITimer(TIM1);

// Init STM32_ISR_Timer
// Each STM32_ISR_Timer can service 16 different ISR-based timers
STM32_ISR_Timer ISR_Timer;

#define TIMER_INTERVAL_0_5S           500L
#define TIMER_INTERVAL_100mS          5    //100ms
#define TIMER_INTERVAL_1_5S           1500L

void TimerHandler()
{
  ISR_Timer.run();
}

// In STM32, avoid doing something fancy in ISR, for example complex Serial.print with String() argument
// The pure simple Serial.prints here are just for demonstration and testing. Must be eliminate in working environment
// Or you can get this run-time error / crash
void doingSomething1()
{
//  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

void doingSomething2()
{
//  digitalWrite(LED_BLUE, !digitalRead(LED_BLUE));
bfbase4ms = true ;
wflag.onebit.bfbase = 1 ;
//  Serial2.write(0x5a);
}
void doingSomething3()
{
  digitalWrite(LED_RED, !digitalRead(LED_RED));
}

void subled(void)
{
    u8 static wcled ;
   
    wcled++ ;
    if(wcled>3)
    {
    wcled = 0 ;   
    sub9();
   
    }
   
}

const unsigned char Bank_Reg[]={
0x33,  //0
0x00,
0x01,
0x03,
0x01,
66,
0x26,    //1Mbps data rate, output power=-5dBm
0x07,
0x00,
0x00,
0x00,
0x00,
0xc3,
0xc4,
0xc5,
0xc6,
0x20,
0x20,
0x20,
0x20,
0x20,
0x00,

};










void subdelay(unsigned int settime)
{
    unsigned int i ;
    i = 0 ;
    while(i<settime)
    {
        i++ ;
    }
   
}


#define     MISO    digitalRead(PA6)
#define     IRQ     digitalRead(PA0)
#define     M0SI0    digitalWrite(PA7, LOW);
#define     M0SI1    digitalWrite(PA7, HIGH);
#define     SCK0    digitalWrite(PA5, LOW);
#define     SCK1    digitalWrite(PA5, HIGH);
#define     CE0        digitalWrite(PB0, LOW);   
#define     CE1        digitalWrite(PB0, HIGH);   
#define     CSN0    digitalWrite(PA4, LOW);
#define     CSN1    digitalWrite(PA4, HIGH);



void SPI_GPIO_Init()
{
  pinMode(PA6, INPUT_PULLUP);
  pinMode(PA7, OUTPUT);
  pinMode(PA5, OUTPUT);
  pinMode(PA4, OUTPUT);
  pinMode(PB0, OUTPUT);
  pinMode(PA0, INPUT_PULLUP);
  pinMode(PB3, OUTPUT);
  pinMode(PA15, OUTPUT);
   pinMode(PB5, OUTPUT);
   
}

unsigned char sub1(unsigned char value)                                    
{         
    u8    racc0 ;                                             
    for(racc0=0;racc0<8;racc0++)   // output 8-bit
        {
        if(value & 0x80){M0SI1;}
        else{M0SI0;    }
        value = (value << 1);           // shift next bit into MSB..
        SCK1;                      // Set SCK high..
        if(MISO){value = value|0x01 ;}
        else{value = value&0xfe ;}
        SCK0;                     
        }
        return(value);         
}

void sub2(unsigned char reg, unsigned char value)                 
{
    CSN0 ;                   // CSN low, init SPI transaction
    sub1(reg|0x20);      // select register
    sub1(value);             // ..and write value to it..
    CSN1;                   // CSN high again
}  

void sub3(unsigned char reg, unsigned char value)                 
{
    CSN0;                   // CSN low, init SPI transaction
    sub1(reg);      // select register
    sub1(value);             // ..and write value to it..
    CSN1;                   // CSN high again
}


unsigned char sub4(unsigned char reg)                              
{                                                           
    unsigned char value,op_status;
    CSN0 ;               // CSN low, initialize SPI communication...
    op_status=sub1(reg);            // Select register to read from..
    value = sub1(0);    // ..then read register value
    CSN1;                // CSN high, terminate SPI communication
    return(value);        // return register value
}

void sub5(void)
{
    u8    racc0 ;  
   
    racc0=sub4(7);
    racc0=racc0&0x80;
    if(racc0 == 0x80){sub3(0x50,0x53);    }   
}

    void        sub6(void)
{
    CSN0    ;
    sub1(0x0a|0x20);
    sub1(0Xd2);  
    sub1(0Xb5);
    sub1(0x99);
    sub1(0xb3);
    sub1(0x41);
    CSN1 ;
    subdelay(10);  

    CSN0    ;
    sub1(0x10|0x20);
    sub1(0Xd2);  
    sub1(0Xb5);
    sub1(0x99);
    sub1(0xb3);
    sub1(0x41);
    CSN1 ;
   
//    sub2(0x02,0x01);
   
}

void sub7(void)
{
    unsigned char   byte_ctr,racc0 ;

    CE0;
    sub5();
    sub6();
   
    subdelay(10);
    sub2(0xE2,0);//flush Tx
    racc0=sub4(0x00);    // read register 0x00's value
    byte_ctr=racc0|0x01;//set bit 1
  sub2( 0x00, byte_ctr); // Set PWR_UP bit, enable CRC(2 length) & Prim:RX. RX_DR enabled.
    CE1;

}

void    sub8(void)
{
    unsigned char sendcount,tempdata ;
   
    sendcount = 0 ;
    sub5();
    while(sendcount<22)
            {
            tempdata = Bank_Reg[sendcount];
            sub2(sendcount,tempdata);
            sendcount++;   
            subdelay(10);
            }
            
    sub3(0x50,0x73);
    sub2(0x1c,0x3f);
    sub2(0x1d,0x07);
    subdelay(100);
    sub7();
   
}

void sub9(void)
{
    u8 racc0 ;
    u8 static wcled ;
if(!IRQ)
      {
   
    CSN0    ;
    subdelay(10);
    sub1(0x61);
//    digitalWrite(LED_BLUE, !digitalRead(LED_BLUE));
    for(racc0=0 ; racc0<7;racc0++)
    {
    Rxdata[racc0] = sub1(0) ;
   

    }
   
   
   
    if((Rxdata[0]==0x55)&&(Rxdata[1]==0xaa)&&(Rxdata[3]==0x03))
    {
        wcled = 0 ;
        if((Rxdata[4]==2))
        {
             bpm1_l;
            bpm2_h ;
            
            
        //    digitalWrite(LED_BLUE, HIGH);
        //    digitalWrite(LED_RED, LOW);
        }
        else if((Rxdata[4]==1))
        {
             bpm1_h;
bpm2_l ;
            
    //        digitalWrite(LED_RED , HIGH);
    //        digitalWrite(LED_BLUE, LOW);
            
            
        }
        else
        {
             bpm1_h;
bpm2_h ;

// digitalWrite(LED_RED , LOW);
//            digitalWrite(LED_BLUE, LOW);


        }
            
        
    }



   
    CSN1    ;
        
          sub2(0x07,0x70);
          sub3(0xE2,0);
        //  Serial.print("RXOK\n");
      }
    else
    {
        wcled++ ;
        if(wcled>10)
        {
            wcled = 0 ;
    //        digitalWrite(LED_BLUE, LOW);
        }
        
    }
}

void    subpoweron(void)
{
    u8 wccheck ;
    wccheck = 0 ;
while(wccheck != 18)
{
sub2(0x05,18);
delay(50);   
wccheck = sub4(0x05);
  if(stringComplete==false)
  {
//  Serial2.write(84);
  stringComplete = true ;

  }
  else
  {
stringComplete=false ;

  //  Serial2.write(14);
   
  }




}
   
   
   
}





void setup()
{




  Serial.begin(9600);


  delay(100);

  Serial.print(F("\nStarting TimerInterruptLEDDemo on ")); Serial.println(BOARD_NAME);
  Serial.println(STM32_TIMER_INTERRUPT_VERSION);
  Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

  // Instantiate HardwareTimer object. Thanks to 'new' instanciation, HardwareTimer is not destructed when setup() function is finished.
  //HardwareTimer *MyTim = new HardwareTimer(Instance);

  // configure pin in output mode

  pinMode(LED_BLUE,     OUTPUT);


  // Interval in microsecs
  if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_MS * 1000, TimerHandler))
  {
    Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(millis());
  }
  else
    Serial.println(F("Can't set ITimer. Select another freq. or timer"));

  // Just to demonstrate, don't use too many ISR Timers if not absolutely necessary
  // You can use up to 16 timer for each ISR_Timer
// ISR_Timer.setInterval(TIMER_INTERVAL_0_5S,  doingSomething1);

// ISR_Timer.setInterval(TIMER_INTERVAL_1_5S,  doingSomething3);
SPI_GPIO_Init();
subpoweron();
sub8();
ISR_Timer.setInterval(TIMER_INTERVAL_100mS,    doingSomething2);
bpm1_l;
bpm2_l ;
}


void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag so the main loop can
    // do something about it:
   
      stringComplete = true;
   
  }
}


void loop()
{
  /* Nothing to do all is done by hardware. Even no interrupt required. */
  if(wflag.onebit.bfbase)
  {
      wflag.onebit.bfbase = 0 ;
      subled();
      wcad = analogRead(PA3);    // read the input pin   
     if(wcad>30)
     {
         digitalWrite(LED_RED , LOW);
     digitalWrite(LED_BLUE, HIGH );
     }   
     else
     {
         digitalWrite(LED_RED , HIGH);
         digitalWrite(LED_BLUE, LOW);
     }
  }
  
}

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:328023 发表于 2023-8-3 08:12 | 只看该作者
本人专业嵌入式开发,软件硬件兼通,15年单片机开发经验,量产产品上千万,这个ARDUINO的确开发效益很高,比keil人性化(当然很多特别功能需要keil实现)但一般应用程序ARDUINO完全可以取代keil
回复

使用道具 举报

板凳
ID:32962 发表于 2023-9-8 06:42 | 只看该作者
分享链接失效了,能再次分享吗?
回复

使用道具 举报

地板
ID:433680 发表于 2023-9-23 11:51 | 只看该作者
你所访问的页面不存在了,能再次分享吗?
回复

使用道具 举报

5#
ID:433680 发表于 2023-9-23 11:52 | 只看该作者
所访问的页面不存在了, 能再次分享吗?
回复

使用道具 举报

6#
ID:1083165 发表于 2023-12-2 14:01 | 只看该作者
楼主您好,链接失效能再分享一次吗?谢谢
回复

使用道具 举报

7#
ID:433680 发表于 2024-4-3 11:03 | 只看该作者
链接失效
啊哦,来晚了,该分享文件已过期
能再分享一次吗?
回复

使用道具 举报

8#
ID:311400 发表于 2024-4-3 14:54 | 只看该作者
来晚了,你所访问的页面不存在了,能再次分享吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表