极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12485|回复: 2

求助:MEGA2560用IO口模拟SPI

[复制链接]
发表于 2015-5-11 08:50:50 | 显示全部楼层 |阅读模式
本帖最后由 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_WIDTH  1  
// 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












本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2015-5-12 00:12:41 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 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;以此类推。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 01:52 , Processed in 0.040567 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表