亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久福利视频一区二区| 色综合欧美在线| www.欧美色图| 欧美一级在线观看| 国产精品色婷婷| 日韩电影免费在线看| 99re这里只有精品6| 精品国产免费视频| 亚洲成国产人片在线观看| 国产精品99久久久久久有的能看| 91久久国产最好的精华液| 国产亚洲精久久久久久| 日韩精品一二三区| 色狠狠一区二区| 国产精品无遮挡| 国产综合色视频| 7777女厕盗摄久久久| 亚洲免费观看视频| 国产精品88av| wwwwww.欧美系列| 另类的小说在线视频另类成人小视频在线 | 亚洲人成在线观看一区二区| 精品一区二区三区视频在线观看 | 欧美老人xxxx18| 亚洲欧美一区二区三区国产精品 | 麻豆成人免费电影| 欧美亚洲禁片免费| 亚洲免费观看在线观看| av在线一区二区三区| 久久先锋影音av| 国内精品伊人久久久久av一坑| 欧美日韩免费视频| 亚洲国产精品久久一线不卡| 一本久道久久综合中文字幕| 亚洲欧美精品午睡沙发| 99麻豆久久久国产精品免费优播| 国产欧美一区二区在线| 懂色av一区二区三区蜜臀 | 国产成人综合网| 中文字幕久久午夜不卡| 国产精品99久久久久久有的能看 | 粉嫩嫩av羞羞动漫久久久| 久久久精品一品道一区| 国产乱理伦片在线观看夜一区| 欧美大胆人体bbbb| 国产精品91xxx| 成人免费在线播放视频| 91福利精品视频| 日韩精品乱码av一区二区| 欧美男女性生活在线直播观看| 亚洲h精品动漫在线观看| 日韩一区二区三| 国产一区999| 自拍偷拍欧美精品| 欧美色欧美亚洲另类二区| 亚洲午夜久久久久久久久久久| 制服丝袜在线91| 国产自产2019最新不卡| 国产精品欧美经典| 日本高清视频一区二区| 亚洲国产日韩一区二区| 91精品欧美久久久久久动漫| 精品一区二区三区欧美| 中文字幕在线观看不卡视频| 欧美三级资源在线| 精一区二区三区| 最新日韩av在线| 欧美r级在线观看| 成人ar影院免费观看视频| 亚洲综合视频在线| 欧美精品一区二区三区蜜臀| 色综合一区二区三区| 免费观看日韩电影| 国产精品国产三级国产专播品爱网| 在线观看视频一区二区| 久久精品国产在热久久| 国产精品国产三级国产普通话三级| 欧美色图12p| 成人免费毛片aaaaa**| 婷婷亚洲久悠悠色悠在线播放| 中文字幕乱码久久午夜不卡| 69p69国产精品| 成人国产精品免费观看动漫 | 日韩欧美综合一区| 91免费在线播放| 久久电影网电视剧免费观看| 亚洲免费观看视频| 国产婷婷色一区二区三区四区 | 福利电影一区二区| 五月婷婷综合网| 亚洲人午夜精品天堂一二香蕉| 精品国产123| 欧美精品一二三| 一本大道久久a久久综合| 国产美女精品在线| 丝袜美腿亚洲综合| 亚洲精品视频免费观看| 国产精品色在线| 久久久久久久综合| 日韩欧美国产小视频| 欧美三级中文字| 一本色道久久综合狠狠躁的推荐| 国产精品一区二区男女羞羞无遮挡| 视频一区二区国产| 亚洲最色的网站| 亚洲男同1069视频| 国产人成一区二区三区影院| 日韩欧美久久一区| 日韩女优电影在线观看| 欧美日本一区二区三区四区| 一本一本大道香蕉久在线精品| 粉嫩aⅴ一区二区三区四区五区 | 色拍拍在线精品视频8848| 成人综合激情网| 顶级嫩模精品视频在线看| 国产麻豆日韩欧美久久| 精品亚洲国内自在自线福利| 久久国产麻豆精品| 日韩高清在线不卡| 日韩av一区二区在线影视| 日韩高清在线电影| 蜜桃精品视频在线观看| 美国十次了思思久久精品导航| 日本成人在线不卡视频| 蜜臀av性久久久久蜜臀aⅴ| 日本特黄久久久高潮| 麻豆精品视频在线观看免费| 久久99这里只有精品| 激情五月播播久久久精品| 久久99精品国产麻豆婷婷洗澡| 免费高清不卡av| 久久99久久精品| 国产精品一线二线三线| 成人精品视频.| www.av亚洲| 欧美体内she精高潮| 欧美一区二区网站| 久久中文字幕电影| 欧美国产精品久久| 亚洲裸体在线观看| 日韩精品成人一区二区在线| 麻豆一区二区在线| 国产一区二区三区香蕉| 成人国产精品免费观看视频| 欧美主播一区二区三区| 91精品国产综合久久蜜臀| 久久先锋影音av鲁色资源| 亚洲欧洲一区二区在线播放| 亚洲国产综合色| 看片的网站亚洲| 不卡一二三区首页| 7777精品伊人久久久大香线蕉经典版下载| 日韩欧美国产麻豆| 色婷婷综合久色| 色婷婷国产精品| 91精品国产综合久久婷婷香蕉 | 在线观看成人小视频| 国产九色sp调教91| 91免费看视频| 国产精品免费观看视频| 国产精品资源网| 久久久久久久久久久久久久久99| 久久精品99国产精品日本| 欧美喷水一区二区| 一级做a爱片久久| 色老头久久综合| 亚洲精品欧美在线| 色www精品视频在线观看| 亚洲人成小说网站色在线| 99综合电影在线视频| 国产精品久久久久久久浪潮网站| 国产成人精品免费看| 国产日韩欧美在线一区| 国产精品亚洲综合一区在线观看| 国产亚洲精品中文字幕| 成人综合在线视频| 亚洲少妇最新在线视频| 91蜜桃免费观看视频| 亚洲国产一二三| 日韩午夜精品电影| 久久69国产一区二区蜜臀| 久久综合九色综合97婷婷 | 欧美国产一区二区| eeuss鲁片一区二区三区| 亚洲视频免费观看| 欧美无乱码久久久免费午夜一区| 香蕉成人啪国产精品视频综合网 | 久久一留热品黄| 国产成人免费9x9x人网站视频| 中文一区二区在线观看| 91麻豆国产自产在线观看| 亚洲国产视频在线| 精品嫩草影院久久| 国产xxx精品视频大全| 亚洲欧美日韩国产综合在线| 欧美男女性生活在线直播观看| 国精产品一区一区三区mba视频| 国产精品乱码人人做人人爱| 欧美专区亚洲专区| 久久99国产精品久久99 |