CH02_While

package cn.pzhu.java.ch02;

public class WhileDemo {

	
	public static void main(String[] args) {
		int i=1;
		int sum=0;
		while(i<10){
			sum+=i;
			i++;
		}
		sum=0;
		do{
			sum+=i;
			i--;
		}while(i>0);

	}

}

uint32 bluetooth_ch9141_read_buff (uint8 *buff, uint32 len) { uint32 data_l = len; fifo_read_buffer(&bluetooth_ch9141_fifo, buff, &data_l, FIFO_READ_AND_CLEAN); return data_l; }uint32 bluetooth_ch9141_send_buff (uint8 *buff, uint32 len) { uint16 time_count = 0; while(len > 30) { time_count = 0; while(BLUETOOTH_CH9141_RTS_PIN && time_count++ < BLUETOOTH_CH9141_TIMEOUT_COUNT) // 如果RTS为低电平,则继续发送数据 delay_ms(1); if(time_count >= BLUETOOTH_CH9141_TIMEOUT_COUNT) return len; // 模块忙,如果允许当前程序使用while等待 则可以使用后面注释的while等待语句替换本if语句 uart_putbuff(BLUETOOTH_CH9141_INDEX, buff, 30); buff += 30; // 地址偏移 len -= 30; // 数量 } time_count = 0; while(BLUETOOTH_CH9141_RTS_PIN && time_count++ < BLUETOOTH_CH9141_TIMEOUT_COUNT) // 如果RTS为低电平,则继续发送数据 delay_ms(1); if(time_count >= BLUETOOTH_CH9141_TIMEOUT_COUNT) return len; // 模块忙,如果允许当前程序使用while等待 则可以使用后面注释的while等待语句替换本if语句 uart_putbuff(BLUETOOTH_CH9141_INDEX, buff, (uint16)len); // 发送最后的数据 return 0; }uint8 bluetooth_ch9141_init (void) { wireless_type = WIRELESS_CH9141; // 本函数使用的波特率为115200 为蓝牙转串口模块的默认波特率 如需其他波特率请使用上位机修改模块参数 fifo_init(&bluetooth_ch9141_fifo, bluetooth_ch9141_buffer, BLUETOOTH_CH9141_BUFFER_SIZE); uart_init(BLUETOOTH_CH9141_INDEX, BLUETOOTH_CH9141_TX_PIN, BLUETOOTH_CH9141_RX_PIN, BLUETOOTH_CH9141_BUAD_RATE, BLUETOOTH_CH9141_TIMER); return 0; }void bluetooth_ch9141_uart_callback (void) { // 读取无线串口的数据 并且置位接收标志 bluetooth_ch9141_data = BLUETOOTH_CH9141_DATA_BUF; fifo_write_buffer(&bluetooth_ch9141_fifo, &bluetooth_ch9141_data, 1); // 存入 FIFO }static fifo_struct bluetooth_ch9141_fifo; static uint8 bluetooth_ch9141_buffer[BLUETOOTH_CH9141_BUFFER_SIZE]; // 数据存放数组 static uint8 bluetooth_ch9141_data;为我设置参数让这些函数可以让HC-05蓝牙工作
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值