標(biāo)題:
瑞薩單片機(jī)四軸飛行器源碼
[打印本頁(yè)]
作者:
lin5422510
時(shí)間:
2017-10-18 15:07
標(biāo)題:
瑞薩單片機(jī)四軸飛行器源碼
附件為瑞薩單片機(jī)做的四軸飛行器源代碼,希望可以幫到大家
所有資料51hei提供下載:
RL78四軸飛行器完美起飛開源代碼.zip
(239.66 KB, 下載次數(shù): 14)
2017-10-18 15:05 上傳
點(diǎn)擊文件名下載附件
瑞薩四軸飛行器
下載積分: 黑幣 -5
單片機(jī)源程序(主程序)如下:
/***********************************************************************************************************************
* 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 */
復(fù)制代碼
作者:
wallace1747
時(shí)間:
2019-8-15 18:24
請(qǐng)問(wèn)是個(gè)瑞薩G12的嗎?
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1