亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人欧美一区二区三区| 日韩av一区二| 亚洲v精品v日韩v欧美v专区| 国产一区二区三区四区五区美女 | 中文在线资源观看网站视频免费不卡| 国产精品免费观看视频| 亚洲成人免费影院| 波多野结衣视频一区| 91精品国产欧美一区二区成人| 国产日韩欧美麻豆| 天天亚洲美女在线视频| thepron国产精品| 久久久久久久综合日本| 亚洲综合图片区| av中文字幕不卡| 精品国产乱码久久| 日本伊人色综合网| 91国内精品野花午夜精品| 国产日本欧美一区二区| 久久国产精品露脸对白| 欧美高清hd18日本| 亚洲综合丝袜美腿| 色婷婷av一区| 亚洲激情自拍视频| 色哟哟亚洲精品| 亚洲欧美日韩一区| 99精品在线免费| 综合色中文字幕| hitomi一区二区三区精品| 中文字幕+乱码+中文字幕一区| 国产精品亚洲一区二区三区在线| 精品国产一区二区三区忘忧草| 日本午夜一区二区| 欧美一级片在线看| 麻豆传媒一区二区三区| 欧美一级二级在线观看| 蜜臀久久99精品久久久久宅男| 欧美日韩大陆一区二区| 午夜精品福利在线| 欧美吻胸吃奶大尺度电影 | 国产精品伦一区| 成人av动漫网站| 综合久久国产九一剧情麻豆| 91在线观看高清| 亚洲视频一二区| 欧美视频你懂的| 日韩电影在线观看电影| 日韩欧美在线影院| 韩国欧美国产1区| 国产精品视频一区二区三区不卡| 99re成人精品视频| 亚洲国产wwwccc36天堂| 欧美一区二区三区视频在线| 精品一区二区三区影院在线午夜| 久久久久久久久岛国免费| av午夜一区麻豆| 亚洲高清视频中文字幕| 精品精品欲导航| 97久久精品人人澡人人爽| 亚洲一区二区三区国产| 日韩一区二区在线免费观看| 欧美日韩1234| 国产精品 日产精品 欧美精品| 国产精品久久久久久久午夜片| 日本道色综合久久| 久久精品国产免费| 亚洲少妇中出一区| 欧美久久久久久久久中文字幕| 久久精品噜噜噜成人88aⅴ| 国产欧美一区二区三区在线看蜜臀| 色8久久精品久久久久久蜜| 奇米影视7777精品一区二区| 中文字幕日韩精品一区| 777亚洲妇女| 成人三级伦理片| 免费精品99久久国产综合精品| 国产精品的网站| 日韩欧美不卡在线观看视频| 91亚洲永久精品| 国产综合久久久久久鬼色| 一区二区高清在线| 国产人妖乱国产精品人妖| 欧美日本免费一区二区三区| 风间由美性色一区二区三区| 日本欧美在线观看| 亚洲欧美日韩一区二区三区在线观看| 精品黑人一区二区三区久久| 欧美日韩一级黄| 99re热这里只有精品免费视频| 国产在线视频一区二区三区| 亚洲一卡二卡三卡四卡| 中文字幕一区二区三区在线不卡| 日韩三级电影网址| 欧美在线视频你懂得| 成人精品国产一区二区4080| 国产尤物一区二区在线| 久久精品国产成人一区二区三区| 亚洲电影中文字幕在线观看| 中文字幕在线不卡视频| 欧美激情综合五月色丁香| 亚洲精品在线三区| 69堂精品视频| 欧美日韩不卡视频| 在线观看日韩毛片| 色偷偷88欧美精品久久久| 波多野结衣欧美| www.亚洲精品| 99视频超级精品| 大胆欧美人体老妇| 成人一区在线看| 成人免费av在线| 成人性色生活片| 99久久综合精品| 91欧美一区二区| 91免费精品国自产拍在线不卡| 99久久免费视频.com| 91在线小视频| 色国产综合视频| 欧美亚洲一区三区| 欧美日韩小视频| 91麻豆精品国产91久久久久 | 蜜桃精品视频在线| 日本午夜一区二区| 黄色日韩三级电影| 国产盗摄女厕一区二区三区| 成人性生交大片免费看中文网站| 成人一级片网址| 欧美中文字幕一二三区视频| 欧美高清一级片在线| 日韩欧美国产一区在线观看| 精品成人在线观看| 日本一区二区视频在线观看| 国产精品国产馆在线真实露脸 | 中文字幕视频一区二区三区久| 国产精品国产三级国产普通话三级 | 欧美撒尿777hd撒尿| 欧美一区二区三区不卡| 亚洲精品在线观| 国产精品久久久久9999吃药| 亚洲靠逼com| 奇米影视一区二区三区| 国产成人在线免费观看| 99精品欧美一区| 在线播放中文字幕一区| 国产日韩亚洲欧美综合| 亚洲色图一区二区三区| 日本三级韩国三级欧美三级| 国产伦精品一区二区三区视频青涩 | 欧美日韩国产一区二区三区地区| 制服丝袜av成人在线看| 久久精品日产第一区二区三区高清版| 国产精品欧美经典| 日韩av电影免费观看高清完整版| 国产91对白在线观看九色| 色94色欧美sute亚洲线路一久| 欧美一二三四区在线| 中文字幕在线不卡一区| 麻豆一区二区三| 色哟哟一区二区在线观看| 欧美精品一区二区三区四区| 亚洲欧美福利一区二区| 国产自产高清不卡| 在线观看av一区二区| 国产日韩亚洲欧美综合| 青青草国产精品97视觉盛宴| eeuss鲁片一区二区三区 | 另类成人小视频在线| 91一区二区在线| 国产亚洲欧洲997久久综合| 一区二区在线观看av| 国产一区二区在线视频| 欧美日韩在线播| 玉米视频成人免费看| 国产不卡在线视频| 日韩一二在线观看| 一区二区三区日韩精品| 国产超碰在线一区| 久久五月婷婷丁香社区| 青娱乐精品视频在线| 欧美视频日韩视频在线观看| 亚洲美女视频在线观看| 国产黄色精品网站| 欧美白人最猛性xxxxx69交| 婷婷国产在线综合| 91视频精品在这里| 亚洲欧美综合色| 成人午夜av电影| 久久久国产一区二区三区四区小说 | 中文字幕在线不卡| 国产成人超碰人人澡人人澡| 久久综合国产精品| 麻豆免费精品视频| 欧美一区二区视频观看视频| 亚洲高清一区二区三区| 欧美性生活大片视频| 亚洲免费视频中文字幕| 91在线小视频| 一区二区三区.www| 欧美亚洲一区二区三区四区| 一区二区三区视频在线看|