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

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

?? nrf24l01.c

?? MSP430的SPI接口的例子程序。連接NRF24L01實現定長的數據包通信
?? 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;
		
	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一区二区三区免费野_久草精品视频
国产成人精品一区二区三区四区| 26uuu精品一区二区| 国产乱子伦一区二区三区国色天香| 亚洲国产sm捆绑调教视频| 一区二区三区欧美在线观看| 伊人婷婷欧美激情| 亚洲黄色在线视频| 性做久久久久久免费观看欧美| 亚洲一线二线三线视频| 日韩在线观看一区二区| 精品一二线国产| 成人永久aaa| 色婷婷精品大视频在线蜜桃视频| 在线看一区二区| 欧美精品一级二级三级| 欧美成人艳星乳罩| 亚洲国产岛国毛片在线| 亚洲精品自拍动漫在线| 亚洲成av人影院| 国产一区二区调教| 日本高清无吗v一区| 91精品国产综合久久香蕉麻豆 | 国产精品午夜久久| 中文字幕一区二区三区四区不卡 | 成人晚上爱看视频| 色综合天天综合色综合av| 欧美日韩国产大片| 久久中文字幕电影| 亚洲品质自拍视频| 精品一区二区三区在线观看| 成人精品电影在线观看| 欧美日本一区二区三区四区| 久久久久久免费毛片精品| 亚洲精品免费电影| 精品一区二区在线视频| 色女孩综合影院| 精品国产一区二区三区久久久蜜月| 国产精品美女久久久久aⅴ| 日韩高清不卡在线| eeuss影院一区二区三区 | 国产视频一区在线播放| 亚洲一区视频在线| 成人污视频在线观看| 欧美一区二区三区小说| 亚洲欧洲日本在线| 国产精品一区二区x88av| 欧美日韩免费观看一区三区| 国产精品免费看片| 国产在线精品免费| 884aa四虎影成人精品一区| 亚洲视频1区2区| 国产成人免费在线观看不卡| 69精品人人人人| 亚洲高清视频的网址| 成人av电影在线观看| 欧美成人免费网站| 日韩福利视频网| 91成人在线观看喷潮| 中文字幕在线观看不卡视频| 激情偷乱视频一区二区三区| 欧美日韩不卡一区| 亚洲午夜影视影院在线观看| 不卡的av电影| 国产无人区一区二区三区| 免费av成人在线| 欧美一级淫片007| 日韩av电影天堂| 欧美精品久久天天躁| 亚洲第一久久影院| 欧美性猛交xxxxxx富婆| 亚洲精品日日夜夜| 色激情天天射综合网| 自拍偷拍亚洲综合| 99久久婷婷国产精品综合| 日本一二三不卡| 不卡在线视频中文字幕| 国产精品久久久久四虎| 成人久久久精品乱码一区二区三区| 精品国产伦理网| 国产精品一区二区在线观看不卡 | 99精品视频一区| 自拍偷拍亚洲激情| 色婷婷激情综合| 午夜精品免费在线观看| 欧美一区二区三区视频在线观看 | 国产日韩在线不卡| 国产·精品毛片| 亚洲三级免费观看| 欧美日韩国产高清一区二区三区| 视频一区欧美日韩| 精品国一区二区三区| 粉嫩aⅴ一区二区三区四区五区 | 亚洲第一福利一区| 欧美一卡二卡在线| 久久一留热品黄| 欧美一区二区三区在线电影| 国产片一区二区| eeuss鲁一区二区三区| 一区二区三区日本| 中文字幕av一区二区三区| 不卡在线观看av| 欧美一区二区三区精品| 另类中文字幕网| 国产精品成人在线观看| 欧洲av在线精品| 国产一区三区三区| 亚洲欧美另类小说| 欧美不卡视频一区| 91在线观看免费视频| 免费久久精品视频| 国产精品成人网| 日韩视频免费观看高清完整版在线观看 | 成人免费高清在线| 午夜在线成人av| 国产精品久久久久久久久久久免费看 | 一卡二卡三卡日韩欧美| 欧美一二区视频| 在线亚洲+欧美+日本专区| 久久国产福利国产秒拍| 亚洲一级二级在线| 中文欧美字幕免费| 日韩欧美一二区| 欧美性受xxxx| 99久久精品国产精品久久| 久久国产精品色| 五月综合激情婷婷六月色窝| 国产精品无圣光一区二区| 在线电影国产精品| 色婷婷激情综合| 成人h版在线观看| 国产一区二区美女诱惑| 日韩avvvv在线播放| 亚洲激情五月婷婷| 亚洲丝袜精品丝袜在线| 国产性色一区二区| 久久综合网色—综合色88| 91精品在线麻豆| 欧美日韩国产电影| 欧美日韩中文另类| 欧美色窝79yyyycom| 91免费看片在线观看| 成人av集中营| eeuss鲁片一区二区三区在线看| 国产一区二区三区久久久 | 中文字幕一区二区三区在线播放 | 国产成人午夜精品影院观看视频| 日本成人在线视频网站| 日韩精品一卡二卡三卡四卡无卡| 一区二区三区国产| 亚洲一二三四区不卡| 一区二区三区四区视频精品免费 | 欧美视频在线不卡| 欧美日韩中字一区| 欧美理论片在线| 欧美另类久久久品| 日韩一区二区三| 精品国产sm最大网站免费看| 日韩欧美一二三四区| 精品国产免费人成电影在线观看四季 | 美国毛片一区二区| 美女脱光内衣内裤视频久久网站 | 日韩精品一区二区三区三区免费 | 欧美做爰猛烈大尺度电影无法无天| av网站一区二区三区| 91天堂素人约啪| 欧美亚洲综合一区| 日韩亚洲欧美综合| 国产日产精品一区| 亚洲欧美色一区| 日韩vs国产vs欧美| 国产麻豆午夜三级精品| 9人人澡人人爽人人精品| 91久久线看在观草草青青| 欧美日韩一区二区三区四区| 日韩视频中午一区| 国产欧美一二三区| 亚洲综合成人在线视频| 老汉av免费一区二区三区 | 亚洲成人精品一区| 美女国产一区二区三区| 成人综合日日夜夜| 欧美群妇大交群的观看方式| 精品久久国产97色综合| 亚洲日本在线观看| 老司机午夜精品| caoporn国产精品| 日韩一级大片在线| 中文字幕亚洲成人| 久久成人免费网| 91丨国产丨九色丨pron| 日韩欧美的一区| 亚洲免费观看在线观看| 美女被吸乳得到大胸91| 色婷婷综合久色| 精品日产卡一卡二卡麻豆| 亚洲精品国产高清久久伦理二区| 精东粉嫩av免费一区二区三区| 色综合天天综合网天天看片| 91丨九色porny丨蝌蚪| 久久不见久久见免费视频1|