Merge pull request #1269 from pkendall64/crsf-max-output
[ExpressLRS.git] / src / lib / SX1280Driver / SX1280_hal.h
blobf1d707b4403ff41ca911f9c1bb71466118afbe88
1 #pragma once
3 /*
4 ______ _
5 / _____) _ | |
6 ( (____ _____ ____ _| |_ _____ ____| |__
7 \____ \| ___ | (_ _) ___ |/ ___) _ \
8 _____) ) ____| | | || |_| ____( (___| | | |
9 (______/|_____)_|_|_| \__)_____)\____)_| |_|
10 (C)2015 Semtech
12 Description: Handling of the node configuration protocol
14 License: Revised BSD License, see LICENSE.TXT file include in the project
16 Maintainer: Miguel Luis and Gregory Cristian
18 Heavily modified/simplified by Alessandro Carcione 2020 for ELRS project
21 #include "SX1280_Regs.h"
22 #include "SX1280.h"
24 enum SX1280_BusyState_
26 SX1280_NOT_BUSY = true,
27 SX1280_BUSY = false,
30 class SX1280Hal
32 public:
33 static SX1280Hal *instance;
35 SX1280Hal();
37 void init();
38 void end();
39 void reset();
41 void ICACHE_RAM_ATTR WriteCommand(SX1280_RadioCommands_t opcode, uint8_t *buffer, uint8_t size);
42 void ICACHE_RAM_ATTR WriteCommand(SX1280_RadioCommands_t command, uint8_t val);
43 void ICACHE_RAM_ATTR WriteRegister(uint16_t address, uint8_t *buffer, uint8_t size);
44 void ICACHE_RAM_ATTR WriteRegister(uint16_t address, uint8_t value);
46 void ICACHE_RAM_ATTR ReadCommand(SX1280_RadioCommands_t opcode, uint8_t *buffer, uint8_t size);
47 void ICACHE_RAM_ATTR ReadRegister(uint16_t address, uint8_t *buffer, uint8_t size);
48 uint8_t ICACHE_RAM_ATTR ReadRegister(uint16_t address);
50 void ICACHE_RAM_ATTR WriteBuffer(uint8_t offset, volatile uint8_t *buffer, uint8_t size); // Writes and Reads to FIFO
51 void ICACHE_RAM_ATTR ReadBuffer(uint8_t offset, volatile uint8_t *buffer, uint8_t size);
53 bool ICACHE_RAM_ATTR WaitOnBusy();
55 void ICACHE_RAM_ATTR TXenable();
56 void ICACHE_RAM_ATTR RXenable();
57 void ICACHE_RAM_ATTR TXRXdisable();
59 static ICACHE_RAM_ATTR void dioISR();
60 void (*IsrCallback)(); //function pointer for callback
62 #if defined(GPIO_PIN_BUSY) && (GPIO_PIN_BUSY != UNDEF_PIN)
63 void BusyDelay(uint32_t duration) const { (void)duration; };
64 #else
65 uint32_t BusyDelayStart;
66 uint32_t BusyDelayDuration;
67 void BusyDelay(uint32_t duration)
69 BusyDelayStart = micros();
70 BusyDelayDuration = duration;
72 #endif