1986chengcheng 发表于 2015-5-11 08:50:50

求助:MEGA2560用IO口模拟SPI

本帖最后由 1986chengcheng 于 2015-5-11 08:54 编辑



本人新手,在做NRF24L01+通讯,想用IO口模拟SPI,该怎么写程序?
源程序:

<nrf24L01.h>

#ifndef NRF24L01_h
#define NRF24L01_h

#include "API.h"

//---------------------------------------------
#define TX_ADR_WIDTH    5   
// 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH1
// 20 unsigned chars TX payload
//---------------------------------------------
#define CE       8
// CE_BIT:   Digital Input   Chip Enable Activates RX or TX mode
#define CSN      9
// CSN BIT:Digital Input   SPI Chip Select
#define SCK      10
// SCK BIT:Digital Input   SPI Clock
#define MOSI   11
// MOSI BIT: Digital Input   SPI Slave Data Input
#define MISO   12
// MISO BIT: Digital Output    SPI Slave Data Output, with tri-state option
#define IRQ      13
// IRQ BIT:Digital Output    Maskable interrupt pin
//*********************************************
#endif












tsaiwn 发表于 2015-5-12 00:12:41



http://blog.csdn.net/special_lin/article/details/12835863

http://m.oschina.net/blog/294948

http://book.51cto.com/art/201304/390512.htm

PINKWALKMAN 发表于 2015-5-12 08:02:46

到2.4G头文件库中改,
//---------------------------------------------
#define CE       8
// CE_BIT:   Digital Input   Chip Enable Activates RX or TX mode
#define CSN      9
// CSN BIT:Digital Input   SPI Chip Select
#define SCK      10
// SCK BIT:Digital Input   SPI Clock
#define MOSI   11
// MOSI BIT: Digital Input   SPI Slave Data Input
#define MISO   12
// MISO BIT: Digital Output    SPI Slave Data Output, with tri-state option
#define IRQ      13
// IRQ BIT:Digital Output    Maskable interrupt pin
//*********************************************
把,后面对应的引脚数字改为你想要的引脚就行,
例如: CE       8改为CE         30;以此类推。
页: [1]
查看完整版本: 求助:MEGA2560用IO口模拟SPI