106 lines
1.8 KiB
C++
106 lines
1.8 KiB
C++
#include "AP0801.h"
|
|
|
|
//#include "Drivers\NRF24L01.h"
|
|
#include "Drivers\W5500.h"
|
|
#include "Drivers\Esp8266\Esp8266.h"
|
|
|
|
AP0801* AP0801::Current = nullptr;
|
|
|
|
AP0801::AP0801()
|
|
{
|
|
LedPins.Add(PD8);
|
|
LedPins.Add(PE15);
|
|
ButtonPins.Add(PE13);
|
|
ButtonPins.Add(PE14);
|
|
|
|
LedInvert = false;
|
|
|
|
Current = this;
|
|
}
|
|
|
|
/******************************** 2401 ********************************/
|
|
|
|
/*int Fix2401(const Buffer& bs)
|
|
{
|
|
//auto& bs = *(Buffer*)param;
|
|
// 微网指令特殊处理长度
|
|
uint rs = bs.Length();
|
|
if(rs >= 8)
|
|
{
|
|
rs = bs[5] + 8;
|
|
//if(rs < bs.Length()) bs.SetLength(rs);
|
|
}
|
|
return rs;
|
|
}
|
|
|
|
ITransport* AP0801::Create2401(SPI spi_, Pin ce, Pin irq, Pin power, bool powerInvert, IDataPort* led)
|
|
{
|
|
debug_printf("\r\n Create2401 \r\n");
|
|
|
|
static Spi spi(spi_, 10000000, true);
|
|
static NRF24L01 nrf;
|
|
nrf.Init(&spi, ce, irq, power);
|
|
|
|
auto tc = TinyConfig::Create();
|
|
if(tc->Channel == 0)
|
|
{
|
|
tc->Channel = 120;
|
|
tc->Speed = 250;
|
|
}
|
|
if(tc->Interval == 0)
|
|
{
|
|
tc->Interval= 40;
|
|
tc->Timeout = 1000;
|
|
}
|
|
|
|
nrf.AutoAnswer = false;
|
|
nrf.DynPayload = false;
|
|
nrf.Channel = tc->Channel;
|
|
//nrf.Channel = 120;
|
|
nrf.Speed = tc->Speed;
|
|
|
|
nrf.FixData = Fix2401;
|
|
|
|
if(WirelessLed) net->Led = CreateFlushPort(WirelessLed);
|
|
|
|
nrf.Master = true;
|
|
|
|
return &nrf;
|
|
}*/
|
|
|
|
/*
|
|
NRF24L01+ (SPI3) | W5500 (SPI2) | TOUCH (SPI3)
|
|
NSS | NSS | PD6 NSS
|
|
CLK | SCK | SCK
|
|
MISO | MISO | MISO
|
|
MOSI | MOSI | MOSI
|
|
PE3 IRQ | PE1 INT(IRQ) | PD11 INT(IRQ)
|
|
PD12 CE | PD13 NET_NRST | NET_NRST
|
|
PE6 POWER | POWER | POWER
|
|
|
|
ESP8266 (COM4)
|
|
TX
|
|
RX
|
|
PD3 RST
|
|
PE2 POWER
|
|
|
|
TFT
|
|
FSMC_D 0..15 TFT_D 0..15
|
|
NOE RD
|
|
NWE RW
|
|
NE1 RS
|
|
PE4 CE
|
|
PC7 LIGHT
|
|
PE5 RST
|
|
|
|
PE13 KEY1
|
|
PE14 KEY2
|
|
|
|
PE15 LED2
|
|
PD8 LED1
|
|
|
|
|
|
USB
|
|
PA11 PA12
|
|
*/
|