标题:
瑞萨单片机四轴飞行器源码
[打印本页]
作者:
lin5422510
时间:
2017-10-18 15:07
标题:
瑞萨单片机四轴飞行器源码
附件为瑞萨单片机做的四轴飞行器源代码,希望可以帮到大家
所有资料51hei提供下载:
RL78四轴飞行器完美起飞开源代码.zip
(239.66 KB, 下载次数: 14)
2017-10-18 15:05 上传
点击文件名下载附件
瑞萨四轴飞行器
下载积分: 黑币 -5
单片机源程序(主程序)如下:
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
*
* Copyright (C) 2011, 2013 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : r_main.c
* Version : CodeGenerator for RL78/G13 V2.00.00.07 [22 Feb 2013]
* Device(s) : R5F100LE
* Tool-Chain : CA78K0R
* Description : This file implements main function.
* Creation Date: 2015/8/5
***********************************************************************************************************************/
/***********************************************************************************************************************
Pragma directive
***********************************************************************************************************************/
/* Start user code for pragma. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
/***********************************************************************************************************************
Includes
***********************************************************************************************************************/
#include "r_cg_macrodriver.h"
#include "r_cg_cgc.h"
#include "r_cg_port.h"
#include "r_cg_serial.h"
#include "r_cg_timer.h"
/* Start user code for include. Do not edit comment generated here */
#include "RF24L01.h"
#include "MPU6050.h"
#include "moto.h"
#include "rc.h"
#include "control.h"
#include "timing.h"
/* End user code. Do not edit comment generated here */
#include "r_cg_userdefine.h"
/***********************************************************************************************************************
Global variables and functions
***********************************************************************************************************************/
/* Start user code for global. Do not edit comment generated here */
unsigned char si=0;
#define BYTE0(x) x&0xff
#define BYTE1(x) (x&0xff00)>>8
MD_STATUS Rstatus;
//unsigned char SYS_INIT_OK = 0;
extern char TxBuf[32];
void UARTA1_Send_AF(void);
/* End user code. Do not edit comment generated here */
void R_MAIN_UserInit(void);
/***********************************************************************************************************************
* Function Name: main
* Description : This function implements main function.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
//R_UART0_Start();
while (1U)
{
//(mpuBuf,1);
//P13.0=0;
//Prepare_Data();
//SetRX_Mode();
//P13.0=1;
//Get_Attitude();
NOP();
//UARTA1_Send_AF();
//NRF_Send_AF();
//DelayUs(32000);
//DelayUs(32000);
//DelayUs(5000);
//P7.6=~P7.6;
//ISendStrS(DEVICE_ADDRESS,0x6b,mpuBuf,1);
}
/* End user code. Do not edit comment generated here */
}
/***********************************************************************************************************************
* Function Name: R_MAIN_UserInit
* Description : This function adds user code before implementing main function.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_MAIN_UserInit(void)
{
/* Start user code. Do not edit comment generated here */
unsigned long time=200000;
EI();
//unsigned long time=100000;
while(time--)NOP();
CreateIICPort();
InitMPU6050();
RF24L01_IO_set();
init_NRF24L01();
R_TAU0_Channel5_Start();
R_TAU0_Channel0_Start();
Pid_init();
/* End user code. Do not edit comment generated here */
}
/* Start user code for adding. Do not edit comment generated here */
void UARTA1_Send_AF(void)
{
unsigned char i,sum;
unsigned int _temp;
TxBuf[0]=0x88;
TxBuf[1]=0xAF;
TxBuf[2]=0x1C;
TxBuf[3]=BYTE1(MPU6050_ACC_LAST.x);
TxBuf[4]=BYTE0(MPU6050_ACC_LAST.x);
TxBuf[5]=BYTE1(MPU6050_ACC_LAST.y);
TxBuf[6]=BYTE0(MPU6050_ACC_LAST.y);
TxBuf[7]=BYTE1(MPU6050_ACC_LAST.z);
TxBuf[8]=BYTE0(MPU6050_ACC_LAST.z);
TxBuf[9]=BYTE1(MPU6050_GYRO_LAST.x);
TxBuf[10]=BYTE0(MPU6050_GYRO_LAST.x);
TxBuf[11]=BYTE1(MPU6050_GYRO_LAST.y);
TxBuf[12]=BYTE0(MPU6050_GYRO_LAST.y);
TxBuf[13]=BYTE1(MPU6050_GYRO_LAST.z);
TxBuf[14]=BYTE0(MPU6050_GYRO_LAST.z);
TxBuf[17]=0;
TxBuf[18]=0;
TxBuf[19]=0;
TxBuf[20]=0;
_temp = (int)(Q_angle.x*100);
TxBuf[21]=BYTE1(_temp);
TxBuf[22]=BYTE0(_temp);
_temp = (int)(Q_angle.y*100);
TxBuf[23]=BYTE1(_temp);
TxBuf[24]=BYTE0(_temp);
TxBuf[25]=0;
TxBuf[26]=0;
sum = 0;
for(i=0;i<31;i++)
sum += TxBuf[i];
TxBuf[31]=sum;
R_UART0_Send((unsigned char*)TxBuf,32);
}
/* End user code. Do not edit comment generated here */
复制代码
作者:
wallace1747
时间:
2019-8-15 18:24
请问是个瑞萨G12的吗?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1