1 /* 2 ______ _ 3 / _____) _ | | 4 ( (____ _____ ____ _| |_ _____ ____| |__ 5 \____ \| ___ | (_ _) ___ |/ ___) _ \ 6 _____) ) ____| | | || |_| ____( (___| | | | 7 (______/|_____)_|_|_| \__)_____)\____)_| |_| 8 (C)2015 Semtech 9 10 Description: Handling of the node configuration protocol 11 12 License: Revised BSD License, see LICENSE.TXT file include in the project 13 14 Maintainer: Miguel Luis, Matthieu Verdy and Benjamin Boulet 15 */ 16 #ifndef __SX1280_HAL_H__ 17 #define __SX1280_HAL_H__ 18 19 #include "hw.h" 20 21 /*! 22 * * \brief Define which DIOs are connected 23 */ 24 #define RADIO_DIO1_ENABLE 1 25 #define RADIO_DIO2_ENABLE 0 26 #define RADIO_DIO3_ENABLE 0 27 28 void SX1280HalWaitOnBusy( void ); 29 30 void SX1280HalInit( DioIrqHandler **irqHandlers ); 31 32 void SX1280HalIoInit( void ); 33 34 /*! 35 * \brief Soft resets the radio 36 */ 37 void SX1280HalReset( void ); 38 39 /*! 40 * \brief Clears the instruction ram memory block 41 */ 42 void SX1280HalClearInstructionRam( void ); 43 44 /*! 45 * \brief Wakes up the radio 46 */ 47 void SX1280HalWakeup( void ); 48 49 /*! 50 * \brief Send a command that write data to the radio 51 * 52 * \param [in] opcode Opcode of the command 53 * \param [in] buffer Buffer to be send to the radio 54 * \param [in] size Size of the buffer to send 55 */ 56 void SX1280HalWriteCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size ); 57 58 /*! 59 * \brief Send a command that read data from the radio 60 * 61 * \param [in] opcode Opcode of the command 62 * \param [out] buffer Buffer holding data from the radio 63 * \param [in] size Size of the buffer 64 */ 65 void SX1280HalReadCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size ); 66 67 /*! 68 * \brief Write data to the radio memory 69 * 70 * \param [in] address The address of the first byte to write in the radio 71 * \param [in] buffer The data to be written in radio's memory 72 * \param [in] size The number of bytes to write in radio's memory 73 */ 74 void SX1280HalWriteRegisters( uint16_t address, uint8_t *buffer, uint16_t size ); 75 76 /*! 77 * \brief Write a single byte of data to the radio memory 78 * 79 * \param [in] address The address of the first byte to write in the radio 80 * \param [in] value The data to be written in radio's memory 81 */ 82 void SX1280HalWriteRegister( uint16_t address, uint8_t value ); 83 84 /*! 85 * \brief Read data from the radio memory 86 * 87 * \param [in] address The address of the first byte to read from the radio 88 * \param [out] buffer The buffer that holds data read from radio 89 * \param [in] size The number of bytes to read from radio's memory 90 */ 91 void SX1280HalReadRegisters( uint16_t address, uint8_t *buffer, uint16_t size ); 92 93 /*! 94 * \brief Read a single byte of data from the radio memory 95 * 96 * \param [in] address The address of the first byte to write in the 97 * radio 98 * 99 * \retval value The value of the byte at the given address in 100 * radio's memory 101 */ 102 uint8_t SX1280HalReadRegister( uint16_t address ); 103 104 /*! 105 * \brief Write data to the buffer holding the payload in the radio 106 * 107 * \param [in] offset The offset to start writing the payload 108 * \param [in] buffer The data to be written (the payload) 109 * \param [in] size The number of byte to be written 110 */ 111 void SX1280HalWriteBuffer( uint8_t offset, uint8_t *buffer, uint8_t size ); 112 113 /*! 114 * \brief Read data from the buffer holding the payload in the radio 115 * 116 * \param [in] offset The offset to start reading the payload 117 * \param [out] buffer A pointer to a buffer holding the data from the radio 118 * \param [in] size The number of byte to be read 119 */ 120 void SX1280HalReadBuffer( uint8_t offset, uint8_t *buffer, uint8_t size ); 121 122 /*! 123 * \brief Returns the status of DIOs pins 124 * 125 * \retval dioStatus A byte where each bit represents a DIO state: 126 * [ DIOx | BUSY ] 127 */ 128 uint8_t SX1280HalGetDioStatus( void ); 129 130 void SX1280HalIoIrqInit( DioIrqHandler **irqHandlers ); 131 132 #endif // __SX1280_HAL_H__ 133