#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "mcu_function.h"
#include "wireless_define.h"
#define SET 1
#define NOT_SET 0
void init_parameter(void);
unsigned char TxRxBuf[4];
volatile struct voltage
{
unsigned char H_data;
unsigned char L_data;
int value;
}current_voltage[8];
volatile unsigned char ad_H;
volatile unsigned char ad_L;
volatile unsigned char current_ADC;
//volatile unsigned char Rxd_buffer[4];
//volatile unsigned char Rxd_buffer_cout;
volatile unsigned char flag_AD;
//volatile unsigned char flag_Rxd;
volatile unsigned char flag_time;
/*
//=====================================================================================
//Function : Delay x us
//=====================================================================================
void Delay(unsigned int us)
{
while ( us-- )
{
;
}
}
//=====================================================================================
//Function : Delay x ms
//=====================================================================================
void Delay_ms( unsigned int ms )
{
unsigned int temp_i;;
while ( ms-- )
{
temp_i = 30;
while(temp_i--);
}
}
*/
int main(void)
{
init_devices();
init_parameter();
DDRC = 0xff;//identify that wheathe the MCU is working.
PORTC = 0x0f;
//unsigned int vol;
//unsigned char uart_trans_L, uart_trans_H;
Spi_initial();
system_Init();
Config905();
_delay_us(500);
_delay_ms(9000);
_delay_ms(9000);
TxRxBuf[0] = 0x44;//If data change failed, the data being get will be 0x44.
TxRxBuf[1] = 0x44;
TxRxBuf[2] = 0x44;
TxRxBuf[3] = 0x44;
while(1)
{
/*
for (current_ADC = 0; current_ADC < 2; current_ADC++)
{
adc_init(current_ADC);
while( flag_time == NOT_SET) //delay 6ms250us
{
if (flag_AD == SET)
{
current_voltage[current_ADC].value = adc_calc();
// ten bits adc.four bits number of the senor.two bits for identifing the high or low of the data.
current_voltage[current_ADC].L_data =
(unsigned char)( (current_voltage[current_ADC].value&0x007F) );
current_voltage[current_ADC].H_data =
(unsigned char)( ((current_voltage[current_ADC].value>>7)|0b10000000))|((current_ADC<<3) );
TxRxBuf[(2*current_ADC)] = current_voltage[current_ADC].H_data;
TxRxBuf[(2*current_ADC+1)] = current_voltage[current_ADC].L_data;
// USART_Transmit( current_voltage[current_ADC].H_data );
// USART_Transmit( current_voltage[current_ADC].L_data );
flag_AD = NOT_SET;
}
// if (flag_Rxd == SET)
// {
// USART_Transmit( Rxd_buffer[0] );
// USART_Transmit( Rxd_buffer[1] );
// flag_Rxd = NOT_SET;
// Rxd_buffer_cout = 0;
// }
}
flag_time = NOT_SET;
}
TxPacket( TxRxBuf ); // 装载待发送数据
SetTxMode( ); // 设置进入发送状态
*/
TxPacket( TxRxBuf ); // 装载待发送数据
SetTxMode( ); // 设置进入发送状态
if( TxRxBuf[3] < 0xf0 ) //DON'T USE (TxRxBuf[3] < 0xf0) FOR JUDGING , FOR AVOIDDING DATA EXCEED.
{
TxRxBuf[0] += 1;
TxRxBuf[1] += 1;
TxRxBuf[2] += 1;
TxRxBuf[3] += 1;
}
else
{
TxRxBuf[0] = 0x01;
TxRxBuf[1] = 0x02;
TxRxBuf[2] = 0x03;
TxRxBuf[3] = 0x04;
}
}
return 0;
}
void init_parameter(void)
{
ad_H = 0;
ad_L = 0;
current_ADC = 0;
// Rxd_buffer[0] = 0;
// Rxd_buffer[1] = 0;
// Rxd_buffer[2] = 0;
// Rxd_buffer[3] = 0;
// Rxd_buffer_cout = 0;
flag_AD = NOT_SET;
// flag_Rxd = NOT_SET;
flag_time = NOT_SET;
}
SIGNAL(SIG_OVERFLOW0)//timer0 function
{
flag_time = SET;
TCNT0 = 0xBC;
}
/*
//串行接收结束中断服务程序
//#pragma interrupt_handler usart_rx_isr:14
//void usart_rx_isr(void)
SIGNAL(SIG_USART_RECV)
{
if (Rxd_buffer_cout == 0)
{
Rxd_buffer[Rxd_buffer_cout] = UDR;
Rxd_buffer_cout++;
}
else if (Rxd_buffer_cout == 1)
{
Rxd_buffer[Rxd_buffer_cout] = UDR;
Rxd_buffer_cout++;
flag_Rxd = SET;
}
//问题处理
else
{
flag_Rxd = NOT_SET;
Rxd_buffer_cout = 0;
Rxd_buffer[Rxd_buffer_cout] = UDR;
Rxd_buffer[1] = 0;
}
}
*/
//#pragma interrupt_handler adc_isr:15
//void adc_isr(void)
SIGNAL(SIG_ADC)
{
flag_AD = SET;
}
NRF905 avr调试程序 GCC 接收速率4kbps已测成功
5星 · 超过95%的资源 需积分: 10 57 浏览量
2011-04-28
08:45:17
上传
评论 1
收藏 191KB RAR 举报
tao2002
- 粉丝: 0
- 资源: 14
最新资源
- 重启进行BIOS快捷方式,不需要开机按BIOS键
- 威纶通触摸屏编程软件Easy builder pro V6.09.01.556安装包(2024.04).txt
- WindowsAdminCenter
- 老飞飞搭建基础通用数据库V19数据库.rar
- jquery.js
- 机械设计多工位ACF贴胶带&预压设备sw18可编辑非常好的设计图纸100%好用.zip
- 基于Pytorch复现Point-Transformer,用于ShapeNet数据集点云分割
- 【医学影像分析】2D超声图像的分割检测(Ultrasound Nerve Segmentation - Kaggle数据集)
- 嘎嘎香的五款神仙谷歌插件
- .arch书源导入教程.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈