亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nrf24l01.c

?? nRF24L01開發指導
?? C
?? 第 1 頁 / 共 3 頁
字號:
/******************************************************************************
*
* File: nrf24l01.c
* 
* Copyright S. Brennen Ball, 2006-2007
* 
* The author provides no guarantees, warantees, or promises, implied or
*	otherwise.  By using this software you agree to indemnify the author
* 	of any damages incurred by using it.
*
*****************************************************************************/

#include "nrf24l01.h"

//Arguments except opt_rx_standby_mode fill the actual register they are named 
//  after. Registers that do not need to be initialized are not included here.
//The argument opt_rx_active_mode is only used if the user is initializing the
//  24L01 as a receiver.  If the argument is false, the receiver will remain in
//  standby mode and not monitor for packets.  If the argument is true, the CE
//  pin will be set and the 24L01 will monitor for packets.  In TX mode, the value
//  of this argument is insignificant.
//If the user wants to leave any 1-byte register in its default state, simply put
//  as that register's argument nrf24l01_<reg>_DEFAULT_VAL, where <reg> is the register
//  name.
//If the user wants to leave any of the 5-byte registers RX_ADDR_P0, RX_ADDR_P1, or 
//  TX_ADDR in its default state, simply put NULL in the argument for that address value.
void nrf24l01_initialize(unsigned char config,
						 unsigned char opt_rx_active_mode,  
						 unsigned char en_aa, 
						 unsigned char en_rxaddr, 
						 unsigned char setup_aw, 
						 unsigned char setup_retr, 
						 unsigned char rf_ch, 
						 unsigned char rf_setup, 
						 unsigned char * rx_addr_p0, 
						 unsigned char * rx_addr_p1, 
						 unsigned char rx_addr_p2, 
						 unsigned char rx_addr_p3, 
						 unsigned char rx_addr_p4, 
						 unsigned char rx_addr_p5, 
						 unsigned char * tx_addr, 
						 unsigned char rx_pw_p0, 
						 unsigned char rx_pw_p1, 
						 unsigned char rx_pw_p2, 
						 unsigned char rx_pw_p3, 
						 unsigned char rx_pw_p4, 
						 unsigned char rx_pw_p5)
{
	unsigned char data[5];

	data[0] = en_aa;
	nrf24l01_write_register(nrf24l01_EN_AA, data, 1);

	data[0] = en_rxaddr;
	nrf24l01_write_register(nrf24l01_EN_RXADDR, data, 1);

	data[0] = setup_aw;
	nrf24l01_write_register(nrf24l01_SETUP_AW, data, 1);

	data[0] = setup_retr;
	nrf24l01_write_register(nrf24l01_SETUP_RETR, data, 1);

	data[0] = rf_ch;
	nrf24l01_write_register(nrf24l01_RF_CH, data, 1);

	data[0] = rf_setup;
	nrf24l01_write_register(nrf24l01_RF_SETUP, data, 1);

	if(rx_addr_p0 != NULL)
		nrf24l01_set_rx_addr(rx_addr_p0, 5, 0);
	else
	{
		data[0] = nrf24l01_RX_ADDR_P0_B0_DEFAULT_VAL;
		data[1] = nrf24l01_RX_ADDR_P0_B1_DEFAULT_VAL;
		data[2] = nrf24l01_RX_ADDR_P0_B2_DEFAULT_VAL;
		data[3] = nrf24l01_RX_ADDR_P0_B3_DEFAULT_VAL;
		data[4] = nrf24l01_RX_ADDR_P0_B4_DEFAULT_VAL;
		
		nrf24l01_set_rx_addr(data, 5, 0);
	}

	if(rx_addr_p1 != NULL)
		nrf24l01_set_rx_addr(rx_addr_p1, 5, 1);
	else
	{
		data[0] = nrf24l01_RX_ADDR_P1_B0_DEFAULT_VAL;
		data[1] = nrf24l01_RX_ADDR_P1_B1_DEFAULT_VAL;
		data[2] = nrf24l01_RX_ADDR_P1_B2_DEFAULT_VAL;
		data[3] = nrf24l01_RX_ADDR_P1_B3_DEFAULT_VAL;
		data[4] = nrf24l01_RX_ADDR_P1_B4_DEFAULT_VAL;
		
		nrf24l01_set_rx_addr(data, 5, 1);
	}

	data[0] = rx_addr_p2;
	nrf24l01_set_rx_addr(data, 1, 2);

	data[0] = rx_addr_p3;
	nrf24l01_set_rx_addr(data, 1, 3);

	data[0] = rx_addr_p4;
	nrf24l01_set_rx_addr(data, 1, 4);

	data[0] = rx_addr_p5;
	nrf24l01_set_rx_addr(data, 1, 5);

	if(tx_addr != NULL)
		nrf24l01_set_tx_addr(tx_addr, 5);
	else
	{
		data[0] = nrf24l01_TX_ADDR_B0_DEFAULT_VAL;
		data[1] = nrf24l01_TX_ADDR_B1_DEFAULT_VAL;
		data[2] = nrf24l01_TX_ADDR_B2_DEFAULT_VAL;
		data[3] = nrf24l01_TX_ADDR_B3_DEFAULT_VAL;
		data[4] = nrf24l01_TX_ADDR_B4_DEFAULT_VAL;
		
		nrf24l01_set_tx_addr(data, 5);
	}

	data[0] = rx_pw_p0;
	nrf24l01_write_register(nrf24l01_RX_PW_P0, data, 1);

	data[0] = rx_pw_p1;
	nrf24l01_write_register(nrf24l01_RX_PW_P1, data, 1);

	data[0] = rx_pw_p2;
	nrf24l01_write_register(nrf24l01_RX_PW_P2, data, 1);

	data[0] = rx_pw_p3;
	nrf24l01_write_register(nrf24l01_RX_PW_P3, data, 1);

	data[0] = rx_pw_p4;
	nrf24l01_write_register(nrf24l01_RX_PW_P4, data, 1);

	data[0] = rx_pw_p5;
	nrf24l01_write_register(nrf24l01_RX_PW_P5, data, 1);

	if((config & nrf24l01_CONFIG_PWR_UP) != 0)
		nrf24l01_power_up_param(opt_rx_active_mode, config);
	else
		nrf24l01_power_down_param(config);
}

//initializes the 24L01 to all default values except the PWR_UP and PRIM_RX bits
//this function also disables the auto-ack feature on the chip (EN_AA register is 0)
//bool rx is true if the device should be a receiver and false if it should be
//  a transmitter.
//unsigned char payload_width is the payload width for pipe 0.  All other pipes
//  are left in their default (disabled) state.
//bool enable_auto_ack controls the auto ack feature on pipe 0.  If true, auto-ack will
//  be enabled.  If false, auto-ack is disabled.
void nrf24l01_initialize_debug(bool rx, unsigned char p0_payload_width, bool enable_auto_ack)
{
	unsigned char config;
	unsigned char en_aa;
	
	config = nrf24l01_CONFIG_DEFAULT_VAL | nrf24l01_CONFIG_PWR_UP;
	
	if(enable_auto_ack != false)
		en_aa = nrf24l01_EN_AA_ENAA_P0;
	else
		en_aa = nrf24l01_EN_AA_ENAA_NONE;
	
	if(rx == true)
		config = config | nrf24l01_CONFIG_PRIM_RX;
		
	nrf24l01_initialize(config, 
						true,
						en_aa, 
						nrf24l01_EN_RXADDR_DEFAULT_VAL, 
						nrf24l01_SETUP_AW_DEFAULT_VAL, 
						nrf24l01_SETUP_RETR_DEFAULT_VAL, 
						nrf24l01_RF_CH_DEFAULT_VAL, 
						nrf24l01_RF_SETUP_DEFAULT_VAL,  
						NULL, 
						NULL, 
						nrf24l01_RX_ADDR_P2_DEFAULT_VAL, 
						nrf24l01_RX_ADDR_P3_DEFAULT_VAL, 
						nrf24l01_RX_ADDR_P4_DEFAULT_VAL, 
						nrf24l01_RX_ADDR_P5_DEFAULT_VAL, 
						NULL, 
						p0_payload_width, 
						nrf24l01_RX_PW_P1_DEFAULT_VAL, 
						nrf24l01_RX_PW_P2_DEFAULT_VAL, 
						nrf24l01_RX_PW_P3_DEFAULT_VAL, 
						nrf24l01_RX_PW_P4_DEFAULT_VAL, 
						nrf24l01_RX_PW_P5_DEFAULT_VAL);
}

//initializes only the CONFIG register and pipe 0's payload width
//the primary purpose of this function is to allow users with microcontrollers with
//  extremely small program memories to still be able to init their 24L01.  This code
//  should have a smaller footprint than the above init functions.
//when using this method, the 24L01 MUST have its default configuration loaded
//  in all registers to work.  It is recommended that the device be reset or
//  have its power cycled immediately before this code is run.
//in normal circumstances, the user should use nrf24l01_initialize() rather than this
//  function, since this function does not set all of the register values.
void nrf24l01_initialize_debug_lite(bool rx, unsigned char p0_payload_width)
{
	unsigned char config;
	
	config = nrf24l01_CONFIG_DEFAULT_VAL;
	
	if(rx != false)
		config |= nrf24l01_CONFIG_PRIM_RX;
		
	nrf24l01_write_register(nrf24l01_RX_PW_P0, &p0_payload_width, 1);
	nrf24l01_power_up_param(true, config);
}

//powers up the 24L01 with all necessary delays
//this function takes the existing contents of the CONFIG register and sets the PWR_UP 
//the argument rx_active_mode is only used if the user is setting up the
//  24L01 as a receiver.  If the argument is false, the receiver will remain in
//  standby mode and not monitor for packets.  If the argument is true, the CE
//  pin will be set and the 24L01 will monitor for packets.  In TX mode, the value
//  of this argument is insignificant.
//note: if the read value of the CONFIG register already has the PWR_UP bit set, this function
//  exits in order to not make an unecessary register write.
void nrf24l01_power_up(bool rx_active_mode)
{
	unsigned char config;
	
	nrf24l01_read_register(nrf24l01_CONFIG, &config, 1);
	
	if((config & nrf24l01_CONFIG_PWR_UP) != 0)
		return;
		
	config |= nrf24l01_CONFIG_PWR_UP;
	
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);
	
	delay_us(1500);
	
	if((config & nrf24l01_CONFIG_PRIM_RX) == 0)
		nrf24l01_clear_ce();
	else
	{
		if(rx_active_mode != false)
			nrf24l01_set_ce();
		else
			nrf24l01_clear_ce();
	}
}

//powers up the 24L01 with all necessary delays
//this function allows the user to set the contents of the CONFIG register, but the function
//  sets the PWR_UP bit in the CONFIG register, so the user does not need to.
//the argument rx_active_mode is only used if the user is setting up the
//  24L01 as a receiver.  If the argument is false, the receiver will remain in
//  standby mode and not monitor for packets.  If the argument is true, the CE
//  pin will be set and the 24L01 will monitor for packets.  In TX mode, the value
//  of this argument is insignificant.
void nrf24l01_power_up_param(bool rx_active_mode, unsigned char config)
{
	unsigned char test, test2;
	
	config |= nrf24l01_CONFIG_PWR_UP;
	
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);

	delay_us(1500);

	if((config & nrf24l01_CONFIG_PRIM_RX) == 0)
		nrf24l01_clear_ce();
	else
	{
		if(rx_active_mode != false)
			nrf24l01_set_ce();
		else
			nrf24l01_clear_ce();
	}
}

//powers down the 24L01
//this function takes the existing contents of the CONFIG register and simply
//  clears the PWR_UP bit in the CONFIG register.
//note: if the read value of the CONFIG register already has the PWR_UP bit cleared, this 
//  function exits in order to not make an unecessary register write.
void nrf24l01_power_down()
{
	unsigned char config;
	
	nrf24l01_read_register(nrf24l01_CONFIG, &config, 1);
	
	if((config & nrf24l01_CONFIG_PWR_UP) == 0)
		return;
	
	config &= (~nrf24l01_CONFIG_PWR_UP);
	
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);

	nrf24l01_clear_ce();
}

//powers down the 24L01
//this function allows the user to set the contents of the CONFIG register, but the function
//  clears the PWR_UP bit in the CONFIG register, so the user does not need to.
void nrf24l01_power_down_param(unsigned char config)
{
	config &= (~nrf24l01_CONFIG_PWR_UP);
	
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);

	nrf24l01_clear_ce();
}


//sets up the 24L01 as a receiver with all necessary delays
//this function takes the existing contents of the CONFIG register and sets the PRIM_RX 
//  bit in the CONFIG register.
//if the argument rx_active_mode is false, the receiver will remain in standby mode
//  and not monitor for packets.  If the argument is true, the CE pin will be set 
//  and the 24L01 will monitor for packets.
//note: if the read value of the CONFIG register already has the PRIM_RX bit set, this function
//  exits in order to not make an unecessary register write.
void nrf24l01_set_as_rx(bool rx_active_mode)
{
	unsigned char config;
	unsigned char status;
	
	status = nrf24l01_read_register(0, &config, 1);

	if((config & nrf24l01_CONFIG_PRIM_RX) != 0)
		return;

	config |= nrf24l01_CONFIG_PRIM_RX;
	
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);

	if(rx_active_mode != false)
		nrf24l01_set_ce();
	else
		nrf24l01_clear_ce();
}

//sets up the 24L01 as a receiver with all necessary delays
//this function allows the user to set the contents of the CONFIG register, but the function
//  sets the PRIM_RX bit in the CONFIG register, so the user does not need to.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀91精品一区二区三区| 成人黄色国产精品网站大全在线免费观看| 日韩一级片在线观看| 国产99久久精品| 视频一区中文字幕国产| 国产精品麻豆网站| 欧美xxxx老人做受| 欧美日韩国产综合一区二区 | 亚洲综合区在线| 亚洲精品一区二区三区四区高清| 在线亚洲高清视频| 成+人+亚洲+综合天堂| 精品一区二区在线免费观看| 亚洲午夜免费视频| 亚洲人成伊人成综合网小说| 国产色产综合产在线视频| 日韩女优av电影| 91精品国产综合久久香蕉的特点| 欧洲精品视频在线观看| 成人av高清在线| 国产一区二区三区日韩| 韩国精品久久久| 美女爽到高潮91| 日韩福利视频导航| 日韩经典一区二区| 午夜精品福利视频网站| 亚洲一区二区在线观看视频| 亚洲精品少妇30p| 亚洲色图欧美激情| 亚洲欧美日韩国产综合在线| 国产精品美女久久久久久久| 国产网站一区二区三区| 国产亚洲1区2区3区| 久久夜色精品国产噜噜av| 精品久久久久香蕉网| 精品少妇一区二区三区| 欧美本精品男人aⅴ天堂| 日韩免费高清av| 精品国产a毛片| 久久久美女艺术照精彩视频福利播放| 日韩亚洲欧美在线观看| 欧美电视剧在线看免费| 精品国产制服丝袜高跟| 久久综合99re88久久爱| 久久久精品tv| 中文字幕第一页久久| 中文字幕制服丝袜一区二区三区| 国产精品麻豆久久久| 亚洲人被黑人高潮完整版| 一区二区三区中文免费| 一个色在线综合| 五月天亚洲精品| 久久综合综合久久综合| 国产一区激情在线| 波多野洁衣一区| 91久久精品一区二区| 制服丝袜亚洲色图| 久久噜噜亚洲综合| 国产精品美女久久久久aⅴ国产馆| 国产精品国产馆在线真实露脸| 亚洲码国产岛国毛片在线| 亚洲自拍偷拍网站| 日韩精品国产欧美| 国产精品白丝av| 91麻豆国产精品久久| 欧美日韩国产在线播放网站| 欧美精品一区二区精品网| 国产精品久久久久久亚洲毛片 | 成人激情免费网站| 在线精品亚洲一区二区不卡| 91精品国产91久久综合桃花| 久久久久久久久久久久久久久99| 中文字幕在线不卡视频| 日韩专区中文字幕一区二区| 国产精品一区2区| 日本精品一区二区三区四区的功能| 日韩一级二级三级| 国产精品久久久久久久久免费樱桃| 亚洲一区二区精品视频| 国产一区二区三区蝌蚪| 色悠悠久久综合| 久久先锋资源网| 一区二区三国产精华液| 国产一区二三区| 欧美日韩中文字幕一区| 国产欧美综合在线观看第十页| 一区二区理论电影在线观看| 国产精品资源在线观看| 欧美天堂一区二区三区| 久久久午夜精品| 青青草精品视频| 色婷婷一区二区| 久久久国产一区二区三区四区小说| 亚洲黄一区二区三区| 福利91精品一区二区三区| 91精选在线观看| 一区二区三区在线视频观看| 国产酒店精品激情| 在线播放日韩导航| 亚洲综合一区在线| 粉嫩av亚洲一区二区图片| 日韩一区二区精品在线观看| 一区二区免费看| 成人久久18免费网站麻豆 | 中文乱码免费一区二区| 蜜桃视频在线一区| 欧美图区在线视频| 亚洲人成小说网站色在线 | 日韩精品一级中文字幕精品视频免费观看 | 免费av成人在线| 欧美三区在线观看| 亚洲人成人一区二区在线观看 | 成人免费视频一区二区| 日韩一级片在线观看| 性感美女极品91精品| 91国产丝袜在线播放| 亚洲欧美日韩中文播放| 成人激情文学综合网| 久久精品人人做人人爽97| 男女视频一区二区| 欧美一区二区久久| 天堂久久久久va久久久久| 欧美在线999| 亚洲在线一区二区三区| kk眼镜猥琐国模调教系列一区二区| 亚洲精品在线三区| 蜜臀精品久久久久久蜜臀| 在线不卡中文字幕播放| 日韩黄色免费电影| 欧洲视频一区二区| 五月婷婷综合激情| 欧美日韩mp4| 日韩精品视频网站| 日韩精品中文字幕一区二区三区| 美女视频第一区二区三区免费观看网站| 欧美福利视频导航| 欧美a级理论片| 精品国精品国产尤物美女| 国产一区二区女| 久久久精品国产免大香伊| 风流少妇一区二区| 国产精品久久精品日日| 99国产精品久久| 一区二区三区四区视频精品免费| 欧美性受xxxx黑人xyx性爽| 午夜电影久久久| 欧美va亚洲va香蕉在线| 国产乱码精品1区2区3区| 国产女人18水真多18精品一级做| 成人午夜电影网站| 亚洲欧美成人一区二区三区| 欧美日本高清视频在线观看| 蜜臀av一区二区| 国产日韩三级在线| 91久久人澡人人添人人爽欧美 | 日韩和的一区二区| 精品国产麻豆免费人成网站| 处破女av一区二区| 一区二区三区在线视频播放| 欧美一区二区三区在线看| 国产成人午夜精品影院观看视频 | 日韩一区二区免费在线电影| 国产精品系列在线观看| 亚洲视频免费观看| 欧美一区二区视频观看视频| 高清国产午夜精品久久久久久| 亚洲欧洲制服丝袜| 欧美一区二区三区免费视频| 国产成人日日夜夜| 亚洲福利电影网| 久久久久久9999| 欧美午夜一区二区三区| 国内成人免费视频| 一区二区久久久| 久久欧美中文字幕| 91在线看国产| 看电视剧不卡顿的网站| 亚洲人亚洲人成电影网站色| 欧美电影一区二区三区| 不卡的av在线播放| 麻豆成人久久精品二区三区小说| 国产精品美女久久久久久久| 欧美一区二区三区免费观看视频| 成人av片在线观看| 久久疯狂做爰流白浆xx| 一区二区三区中文字幕在线观看| 精品国产精品网麻豆系列| 色婷婷综合久色| 国产一区 二区| 日韩国产欧美一区二区三区| 最新热久久免费视频| 精品国产自在久精品国产| 欧美日韩一级片在线观看| 成人app软件下载大全免费| 看国产成人h片视频| 亚洲超碰97人人做人人爱| 亚洲欧洲日产国产综合网| 欧美精品一区二区在线播放| 欧美三区在线视频| 91欧美一区二区|