r g / SX1276GenericLib-us915

Dependents:   DISCO-L072CZ-LRWAN1_LoRa_PingPong

Fork of SX1276GenericLib by Helmut Tschemernjak

Files at this revision

API Documentation at this revision

Comitter:
Helmut Tschemernjak
Date:
Thu May 18 11:07:46 2017 +0200
Parent:
51:aef3234bcb71
Child:
53:6d3adad59633
Commit message:
Added the void * changes into the Arduino HAL version

Changed in this revision

sx1276/sx1276-arduino-hal.cpp Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-arduino-hal.h Show annotated file Show diff for this revision Revisions of this file
--- a/sx1276/sx1276-arduino-hal.cpp	Wed May 17 15:40:13 2017 +0200
+++ b/sx1276/sx1276-arduino-hal.cpp	Thu May 18 11:07:46 2017 +0200
@@ -389,38 +389,40 @@
     return data;
 }
 
-void SX1276Generic::Write( uint8_t addr, uint8_t *buffer, uint8_t size )
+void SX1276Generic::Write( uint8_t addr, void *buffer, uint8_t size )
 {
     uint8_t i;
+    uint8_t *p = (uint8_t *)buffer;
     
     *_nss = 0; // what about SPI hold/release timing on fast MCUs? Helmut
     _spi->write( addr | 0x80 );
     for( i = 0; i < size; i++ )
     {
-        _spi->write( buffer[i] );
+        _spi->write(*p++);
     }
     *_nss = 1;
 }
 
-void SX1276Generic::Read( uint8_t addr, uint8_t *buffer, uint8_t size )
+void SX1276Generic::Read( uint8_t addr, void *buffer, uint8_t size )
 {
     uint8_t i;
+    uint8_t *p = (uint8_t *)buffer;
     
     *_nss = 0; // what about SPI hold/release timing on fast MCUs? Helmut
     _spi->write( addr & 0x7F );
     for( i = 0; i < size; i++ )
     {
-        buffer[i] = _spi->write( 0 );
+        *p++ = _spi->write( 0 );
     }
     *_nss = 1;
 }
 
-void SX1276Generic::WriteFifo( uint8_t *buffer, uint8_t size )
+void SX1276Generic::WriteFifo( void *buffer, uint8_t size )
 {
     Write( 0, buffer, size );
 }
 
-void SX1276Generic::ReadFifo( uint8_t *buffer, uint8_t size )
+void SX1276Generic::ReadFifo( void *buffer, uint8_t size )
 {
     Read( 0, buffer, size );
 }
--- a/sx1276/sx1276-arduino-hal.h	Wed May 17 15:40:13 2017 +0200
+++ b/sx1276/sx1276-arduino-hal.h	Thu May 18 11:07:46 2017 +0200
@@ -80,7 +80,7 @@
     typedef void (SX1276Generic::*Trigger)(void);
     
     
-public:
+    public:
     SX1276Generic( RadioEvents_t *events, BoardType_t board,
                   PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
                   PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5,
@@ -164,7 +164,7 @@
      */
     virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0);
     
-public:
+    public:
     
     /*!
      * @brief Detect the board connected by reading the value of the antenna switch pin
@@ -202,7 +202,7 @@
      * @param [IN] buffer Buffer containing the new register's values
      * @param [IN] size   Number of registers to be written
      */
-    virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
+    virtual void Write( uint8_t addr, void *buffer, uint8_t size ) ;
     
     /*!
      * @brief Reads multiple radio registers starting at address
@@ -211,7 +211,7 @@
      * @param [OUT] buffer Buffer where to copy the registers data
      * @param [IN] size Number of registers to be read
      */
-    virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
+    virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) ;
     
     /*!
      * @brief Writes the buffer contents to the SX1276 FIFO
@@ -219,7 +219,7 @@
      * @param [IN] buffer Buffer containing data to be put on the FIFO.
      * @param [IN] size Number of bytes to be written to the FIFO
      */
-    virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ;
+    virtual void WriteFifo( void *buffer, uint8_t size ) ;
     
     /*!
      * @brief Reads the contents of the SX1276 FIFO
@@ -227,7 +227,7 @@
      * @param [OUT] buffer Buffer where to copy the FIFO read data.
      * @param [IN] size Number of bytes to be read from the FIFO
      */
-    virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ;
+    virtual void ReadFifo( void *buffer, uint8_t size ) ;
     
     /*!
      * @brief Reset the SX1276