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

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

?? nrf24l01.c

?? 介紹NRF24L01的多通道(Multiple Pipes),其中文件nrf24l01.c實現此射頻芯片在多通道下的通信
?? C
?? 第 1 頁 / 共 3 頁
字號:
//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.
void nrf24l01_set_as_rx_param(bool rx_active_mode, unsigned char config)
{
	config |= nrf24l01_CONFIG_PRIM_RX;
	
	if((config & nrf24l01_CONFIG_PWR_UP) != 0)
		nrf24l01_power_up_param(rx_active_mode, config);
	else
		nrf24l01_power_down_param(config);
}

//takes a 24L01 that is already in RX standby mode and puts it in active RX mode
void nrf24l01_rx_standby_to_active()
{
	nrf24l01_set_ce();
}

//takes a 24L01 that is already in active RX mode and puts it in RX standy mode
void nrf24l01_rx_active_to_standby()
{
	nrf24l01_clear_ce();
}

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

	nrf24l01_clear_ce();
}

//sets up the 24L01 as a transmitter
//this function allows the user to set the contents of the CONFIG register, but the function
//  clears the PRIM_RX bit in the CONFIG register, so the user does not need to.
void nrf24l01_set_as_tx_param(unsigned char config)
{
	config &= ~(nrf24l01_CONFIG_PRIM_RX);
	
	if((config & nrf24l01_CONFIG_PWR_UP) != 0)
		nrf24l01_power_up_param(false, config);
	else
		nrf24l01_power_down_param(config);
}

//executes the W_REGISTER SPI operation
//unsigned char regnumber indicates the register number assigned by the nrf24l01 specification.
//  For regnumber values, see section titled "register definitions" in nrf24l01.h.
//unsigned char * data should be of size 1 for all register writes except for RX_ADDR_P0, RX_ADDR_P1,
//	and TX_ADDR.  The size of data should be set according to the user-specified size of the address
//  length for the register the address is being sent to.
//unsigned int len is always the size of unsigned char * data.  For example, if data is declared as
//  data[6], len should equal 6.
//returns the value of the STATUS register
unsigned char nrf24l01_write_register(unsigned char regnumber, unsigned char * data, unsigned int len)
{
	return nrf24l01_execute_command(nrf24l01_W_REGISTER | (regnumber & nrf24l01_W_REGISTER_DATA), data, len, false);
}

//executes the R_REGISTER SPI operation
//unsigned char regnumber indicates the register number assigned by the nrf24l01 specification.
//  For regnumber values, see section titled "register definitions" in nrf24l01.h.
//unsigned char * data should be of size 1 for all register writes except for RX_ADDR_P0, RX_ADDR_P1,
//	and TX_ADDR.  The size of data should be set according to the user-specified size of the address
//  length for the register the address is being read from.
//unsigned int len is always the size of unsigned char * data.  For example, if data is declared as 
//  data[6], len = 6.
//returns the value of the STATUS register
unsigned char nrf24l01_read_register(unsigned char regnumber, unsigned char * data, unsigned int len)
{
	return nrf24l01_execute_command(regnumber & nrf24l01_R_REGISTER_DATA, data, len, true);
}

//executes the W_TX_PAYLOAD operation
//unsigned char * data is the actual payload to be sent to the nrf24l01.
//unsigned int len is the length of the payload being sent (this should be sized
//	according to the payload length specified by the receiving nrf24l01).
//if bool transmit is true, the nrf24l01 immediately transmits the data in the payload.
//	if false, the user must use the nrf24l01_transmit() function to send the payload.
//returns the value of the STATUS register
unsigned char nrf24l01_write_tx_payload(unsigned char * data, unsigned int len, bool transmit)
{
	unsigned char status;
	
	status = nrf24l01_execute_command(nrf24l01_W_TX_PAYLOAD, data, len, false);
	
	if(transmit == true)
		nrf24l01_transmit();
	
	return status;
}

//executes the R_RX_PAYLOAD instruction
//unsigned char * data is the actual payload that has been received by the nrf24l01.
//	The user must size data according to the payload width specified to the nrf24l01.
//	This variable is filled by this function, so individual byte values need not be
//	initialized by the user.
//unsigned int len is the length of the payload being clocked out of the nrf24l01 (this
//	should be sized according to the payload length specified to the nrf24l01).
//returns the value of the STATUS register
unsigned char nrf24l01_read_rx_payload(unsigned char * data, unsigned int len)
{
	unsigned char status;
	
	nrf24l01_clear_ce();
	status = nrf24l01_execute_command(nrf24l01_R_RX_PAYLOAD, data, len, true);
	nrf24l01_set_ce();
	
	return status;
}

//executes the FLUSH_TX SPI operation
//this funciton empties the contents of the TX FIFO
//returns the value of the STATUS register
unsigned char nrf24l01_flush_tx()
{
	return nrf24l01_execute_command(nrf24l01_FLUSH_TX, NULL, 0, true);
}

//executes the FLUSH_RX SPI operation
//this funciton empties the contents of the RX FIFO
//returns the value of the STATUS register
unsigned char nrf24l01_flush_rx()
{
	return nrf24l01_execute_command(nrf24l01_FLUSH_RX, NULL, 0, true);
}

//executes the REUSE_TX_PL SPI operation
//this funciton allows the user to constantly send a packet repeatedly when issued.
//returns the value of the STATUS register
unsigned char nrf24l01_reuse_tx_pl()
{
	return nrf24l01_execute_command(nrf24l01_REUSE_TX_PL, NULL, 0, true);
}

//executes the FLUSH_TX SPI operation
//this funciton does nothing
//returns the value of the STATUS register
unsigned char nrf24l01_nop()
{
	return nrf24l01_execute_command(nrf24l01_NOP, NULL, 0, true);
}

//transmits the current tx payload
void nrf24l01_transmit()
{
	nrf24l01_set_ce();
	delay_us(10);
	nrf24l01_clear_ce();
}

//clears the pin on the host microcontroller that is attached to the 24l01's CE pin
void nrf24l01_clear_ce()
{
	nrf24l01_CE_IOREGISTER &= ~nrf24l01_CE_PINMASK;
}

//sets the pin on the host microcontroller that is attached to the 24l01's CE pin
void nrf24l01_set_ce()
{
	nrf24l01_CE_IOREGISTER |= nrf24l01_CE_PINMASK;
}

//returns true if CE is high, false if not
bool nrf24l01_ce_pin_active()
{
	if((nrf24l01_CE_IOREGISTER & nrf24l01_CE_PINMASK) != 0)
		return true;
	else
		return false;
}

//sets the pin on the host microcontroller that is attached to the 24l01's CSN pin
void nrf24l01_clear_csn()
{
	nrf24l01_CSN_IOREGISTER &= ~nrf24l01_CSN_PINMASK;
}

//clears the pin on the host microcontroller that is attached to the 24l01's CSN pin
void nrf24l01_set_csn()
{
	nrf24l01_CSN_IOREGISTER |= nrf24l01_CSN_PINMASK;
}

//returns true if CSN is high, false if not
bool nrf24l01_csn_pin_active()
{
	if((nrf24l01_CSN_IOREGISTER & nrf24l01_CSN_PINMASK) != 0)
		return true;
	else
		return false;	
}

//sets the TX address in the TX_ADDR register
//unsigned char * address is the actual address to be used.  It should be sized
//	according to the tx_addr length specified to the nrf24l01.
//unsigned int len is the length of the address.  Its value should be specified
//	according to the tx_addr length specified to the nrf24l01.
void nrf24l01_set_tx_addr(unsigned char * address, unsigned int len)
{		
	nrf24l01_write_register(nrf24l01_TX_ADDR, address, len);
}

//sets the RX address in the RX_ADDR register that is offset by rxpipenum
//unsigned char * address is the actual address to be used.  It should be sized
//	according to the rx_addr length that is being filled.
//unsigned int len is the length of the address.  Its value should be specified
//	according to the rx_addr length specified to the nrf24l01.
//unsigned char rxpipenum is the pipe number (zero to five) whose address is being
//	specified.  If an invalid address (greater than five) is supplied, the function
//  does nothing.
void nrf24l01_set_rx_addr(unsigned char * address, unsigned int len, unsigned char rxpipenum)
{	
	if(rxpipenum > 5)
		return;
		
	nrf24l01_write_register(nrf24l01_RX_ADDR_P0 + rxpipenum, address, len);
}

//sets the RX payload width on the pipe offset by rxpipenum
//unsigned char payloadwidth is the length of the payload for the pipe referenced in
//  rxpipenum.  It must be less than or equal to 32.  If an invalid payload width is
//  specified, the function does nothing.
//unsigned char rxpipenum is the pipe number (zero to five) whose address is being
//	specified.  If an invalid address (greater than five) is supplied, the function
//  does nothing.
void nrf24l01_set_rx_pw(unsigned char payloadwidth, unsigned char rxpipenum)
{
	if((rxpipenum > 5) || (payloadwidth > 32))
		return;
		
	nrf24l01_write_register(nrf24l01_RX_PW_P0 + rxpipenum, &payloadwidth, 1);
}

//gets the RX payload width on the pipe offset by rxpipenum
//unsigned char rxpipenum is the pipe number (zero to five) whose address is being
//	specified.  If an invalid address (greater than five) is supplied, the function
//  does nothing.
unsigned char nrf24l01_get_rx_pw(unsigned char rxpipenum)
{
	unsigned char data;
	
	if((rxpipenum > 5))
		return 0;
		
	nrf24l01_read_register(nrf24l01_RX_PW_P0 + rxpipenum, &data, 1);
	
	return data;
}

//returns the value of the CONFIG register
unsigned char nrf24l01_get_config()
{
	unsigned char data;
	
	nrf24l01_read_register(nrf24l01_CONFIG, &data, 1);
	
	return data;
}

//sets the value of the CONFIG register
void nrf24l01_set_config(unsigned char config)
{
	nrf24l01_write_register(nrf24l01_CONFIG, &config, 1);
}

//returns the current RF channel in RF_CH register
unsigned char nrf24l01_get_rf_ch()
{
	unsigned char data;
	
	nrf24l01_read_register(nrf24l01_RF_CH, &data, 1);
	
	return data;
}

//unsigned char channel is the channel to be changed to.
void nrf24l01_set_rf_ch(unsigned char channel)
{
	unsigned char data;
	
	data = channel & ~nrf24l01_RF_CH_RESERVED;
	
	nrf24l01_write_register(nrf24l01_RF_CH, &data, 1);
}

//returns the value of the OBSERVE_TX register
unsigned char nrf24l01_get_observe_tx()
{
	unsigned char data;
	
	nrf24l01_read_register(nrf24l01_OBSERVE_TX, &data, 1);
	
	return data;
}

//returns the current PLOS_CNT value in OBSERVE_TX register
unsigned char nrf24l01_get_plos_cnt()
{
	unsigned char data;
	
	nrf24l01_read_register(nrf24l01_OBSERVE_TX, &data, 1);
	
	return ((data & nrf24l01_OBSERVE_TX_PLOS_CNT) >> 4);
}

//clears the PLOS_CNT field of the OBSERVE_TX register
//this function makes a read of the current value of RF_CH and
//  simply writes it back to the register, clearing PLOS_CNT
void nrf24l01_clear_plos_cnt()
{
	unsigned char data;
	
	nrf24l01_read_register(nrf24l01_RF_CH, &data, 1);
	nrf24l01_write_register(nrf24l01_RF_CH, &data, 1);
}

//clears the PLOS_CNT field of the OBSERVE_TX register
//this function allows the user to set the RF_CH register by using
//  the argument in the function during the PLOS_CNT clearing process
void nrf24l01_clear_plos_cnt_param(unsigned char rf_ch)
{
	nrf24l01_write_register(nrf24l01_RF_CH, &rf_ch, 1);
}

//returns the current ARC_CNT value in OBSERVE_TX register

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产精选| 国产精品久久久久aaaa樱花| 精品国产免费一区二区三区四区 | 久久影视一区二区| 中文字幕一区二区在线播放| 亚洲自拍偷拍图区| 久久国产剧场电影| 成人av小说网| 777久久久精品| 日韩一区在线播放| 午夜精品福利久久久| 成人激情动漫在线观看| 精品1区2区3区| 国产日韩一级二级三级| 婷婷开心激情综合| 91在线云播放| 日韩一级二级三级精品视频| 欧美激情综合五月色丁香小说| 亚洲一区在线视频| 成人app软件下载大全免费| 日韩一级大片在线观看| 亚洲一二三专区| 91亚洲精品久久久蜜桃| 精品99999| 日韩av一级片| 91精品蜜臀在线一区尤物| 国产精品久久久久四虎| 国精品**一区二区三区在线蜜桃| 色八戒一区二区三区| 国产精品美女一区二区| 国产电影一区在线| 国产校园另类小说区| 国模少妇一区二区三区| 欧美一卡2卡三卡4卡5免费| 亚洲第一久久影院| 这里是久久伊人| 日韩福利电影在线| 国产三级三级三级精品8ⅰ区| 国产欧美一区二区三区沐欲| 香港成人在线视频| 一本色道综合亚洲| 国产精品麻豆网站| av影院午夜一区| 日韩免费高清av| 蜜臀久久久99精品久久久久久| 欧美系列亚洲系列| 午夜激情综合网| 日韩一区二区免费高清| 久久99精品国产麻豆婷婷| 日韩丝袜美女视频| 美腿丝袜一区二区三区| 久久精品视频一区二区| 粉嫩一区二区三区性色av| 日韩欧美电影一区| 国产+成+人+亚洲欧洲自线| 中文字幕第一区综合| av一区二区三区黑人| 亚洲最新视频在线播放| 欧美人伦禁忌dvd放荡欲情| 麻豆精品国产传媒mv男同| 久久网这里都是精品| 国产成人精品免费视频网站| 亚洲国产欧美日韩另类综合| 在线不卡欧美精品一区二区三区| 日产精品久久久久久久性色| 久久日韩精品一区二区五区| av亚洲精华国产精华精华 | 另类小说一区二区三区| 国产精品嫩草影院com| 欧美少妇一区二区| 国产一区二区主播在线| 亚洲女女做受ⅹxx高潮| 欧美日本一区二区三区| 99精品桃花视频在线观看| 日本视频一区二区三区| 亚洲欧洲精品成人久久奇米网| 欧美午夜免费电影| 成人污污视频在线观看| 日韩精品午夜视频| 亚洲欧美福利一区二区| 日韩一级高清毛片| 在线国产亚洲欧美| 波多野结衣欧美| 麻豆精品视频在线| 青青草原综合久久大伊人精品 | 9久草视频在线视频精品| 欧美a级理论片| 日韩高清欧美激情| 一区二区三区产品免费精品久久75| 久久久三级国产网站| 日韩一区二区三区免费观看| 欧美日韩精品一区视频| 91免费在线看| 欧美怡红院视频| 99精品欧美一区二区三区小说| bt欧美亚洲午夜电影天堂| 成人免费电影视频| 国产激情一区二区三区桃花岛亚洲| 精久久久久久久久久久| 丝袜亚洲另类欧美综合| 日韩不卡一区二区三区| 日韩激情在线观看| 久久精品国产久精国产| 免费人成在线不卡| 麻豆精品一区二区av白丝在线 | 国模套图日韩精品一区二区| 久久99精品一区二区三区 | 91麻豆精品国产91久久久久久久久| 一本大道久久精品懂色aⅴ| 色婷婷狠狠综合| 欧美三区在线视频| 精品入口麻豆88视频| 国产亲近乱来精品视频| 日本一二三不卡| 一区二区三区高清不卡| 久久精品国内一区二区三区| 国产一区二区剧情av在线| 成人一区在线看| 欧美专区日韩专区| 久久亚洲私人国产精品va媚药| 中文字幕成人在线观看| 亚洲一区二区三区四区五区黄| 久久国产精品第一页| 成人精品免费视频| 6080日韩午夜伦伦午夜伦| 精品av综合导航| 亚洲电影一区二区| 激情文学综合插| 在线免费观看成人短视频| 精品久久久影院| 亚洲大片一区二区三区| 97精品国产97久久久久久久久久久久| 在线播放/欧美激情| 久久精品亚洲乱码伦伦中文| 日韩精品一级二级| 91欧美一区二区| 中文在线一区二区| 国产乱码精品一品二品| 欧美日韩在线精品一区二区三区激情 | 99精品视频中文字幕| 精品福利在线导航| 亚洲综合视频网| 成人免费观看男女羞羞视频| 精品国产污网站| 日本伊人色综合网| 色综合久久综合| 1区2区3区欧美| 不卡在线视频中文字幕| 日韩午夜激情免费电影| 首页综合国产亚洲丝袜| 91国产丝袜在线播放| 国产精品毛片大码女人| 国产揄拍国内精品对白| 欧美一区二区三区免费观看视频| 一区二区三区国产| 91精品综合久久久久久| 一区二区三区中文在线观看| 欧美亚洲综合另类| 亚洲精选一二三| 欧美色视频在线观看| 亚洲精品成人天堂一二三| a亚洲天堂av| 夜夜嗨av一区二区三区中文字幕 | 欧美日韩大陆在线| 视频在线观看国产精品| 欧美一区二区视频观看视频| 美女视频一区二区| 日韩免费一区二区| 国产99久久精品| 中文欧美字幕免费| 欧美日韩亚洲另类| 狠狠狠色丁香婷婷综合激情 | 久久五月婷婷丁香社区| 91丝袜国产在线播放| 亚洲成人福利片| 日韩视频一区在线观看| 99久久er热在这里只有精品15| 日日嗨av一区二区三区四区| www成人在线观看| 99久久er热在这里只有精品15| 一区二区三区四区不卡在线| 欧美日韩成人在线一区| 成人午夜av电影| 麻豆精品精品国产自在97香蕉| 国产女人aaa级久久久级| 欧美一区二区视频免费观看| 九色porny丨国产精品| 亚洲一区二区四区蜜桃| 久久久久国产成人精品亚洲午夜| 99re热这里只有精品视频| 免费人成网站在线观看欧美高清| 国产精品视频一二三| 欧美一区二区视频免费观看| 色噜噜狠狠成人网p站| 国产.欧美.日韩| 日韩精品电影一区亚洲| 午夜精品福利一区二区三区蜜桃| 国产精品久久福利| 国产精品少妇自拍| 中文字幕乱码日本亚洲一区二区|