Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong
Fork of SX1276GenericLib by
Revision 51:aef3234bcb71, committed 2017-05-17
- Comitter:
- Helmut Tschemernjak
- Date:
- Wed May 17 15:40:13 2017 +0200
- Parent:
- 50:43f7160e869c
- Child:
- 52:4d304485eda0
- Commit message:
- Added proper void * type from sending data, uint8_t * is not appropriate.
Use also void pointer for FiFo Write/Read and regular SPI Read/Write
Changed in this revision
--- a/LoRa_TODO.txt Tue May 16 17:51:21 2017 +0200 +++ b/LoRa_TODO.txt Wed May 17 15:40:13 2017 +0200 @@ -16,7 +16,8 @@ it is a good idea to split the OnTimeoutIrq function into separate callbacks for RX/TX/Cad timeouts - Test if the SX1276 timeouts. Does rx/tx/sync really uses three different - timers or just one at a time. + timers or just one at a time. +- Add API to set the LNA gain Done: @@ -31,3 +32,6 @@ - Added radio API support to receive the MaxMTUSize (May 2017 Helmut) - Added Send optional Send() parameter to include a header, this saves additional buffers. (May 2017 Helmut) +- Added proper void * type from sending data, uint8_t * is not appropriate (May 2017 Helmut) +- Use also void pointer for FiFo Write/Read and regular SPI Read/Write +
--- a/radio/radio.h Tue May 16 17:51:21 2017 +0200
+++ b/radio/radio.h Wed May 17 15:40:13 2017 +0200
@@ -353,7 +353,7 @@
* @param [IN]: buffer Header pointer
* @param [IN]: size Header size
*/
- virtual void Send( uint8_t *buffer, uint8_t size, uint8_t *header = NULL, uint8_t hsize = 0) = 0;
+ virtual void Send( void *buffer, int16_t size, void *header = NULL, int16_t hsize = 0) = 0;
/*!
* @brief Sets the radio in sleep mode
@@ -430,7 +430,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 ) = 0;
+ virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0;
/*!
* @brief Reads multiple radio registers starting at address
@@ -439,7 +439,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 ) = 0;
+ virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0;
/*!
* @brief Writes the buffer contents to the Radio FIFO
@@ -447,7 +447,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 ) = 0;
+ virtual void WriteFifo( void *buffer, uint8_t size ) = 0;
/*!
* @brief Reads the contents of the Radio FIFO
@@ -455,7 +455,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 ) = 0;
+ virtual void ReadFifo( void *buffer, uint8_t size ) = 0;
/*!
* @brief Sets the maximum payload length.
--- a/sx1276/sx1276-mbed-hal.cpp Tue May 16 17:51:21 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.cpp Wed May 17 15:40:13 2017 +0200
@@ -392,38 +392,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-mbed-hal.h Tue May 16 17:51:21 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.h Wed May 17 15:40:13 2017 +0200
@@ -201,7 +201,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
@@ -210,7 +210,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
@@ -218,7 +218,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
@@ -226,7 +226,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
--- a/sx1276/sx1276.cpp Tue May 16 17:51:21 2017 +0200
+++ b/sx1276/sx1276.cpp Wed May 17 15:40:13 2017 +0200
@@ -633,7 +633,7 @@
return airTime;
}
-void SX1276::Send( uint8_t *buffer, uint8_t size, uint8_t *header, uint8_t hsize )
+void SX1276::Send( void *buffer, int16_t size, void *header, int16_t hsize )
{
uint32_t txTimeout = 0;
@@ -664,7 +664,7 @@
WriteFifo( header, hsize );
memcpy( rxtxBuffer, header, hsize );
}
- memcpy( rxtxBuffer+hsize, buffer+hsize, size );
+ memcpy( rxtxBuffer+hsize, (uint8_t *)buffer+hsize, size );
this->settings.FskPacketHandler.ChunkSize = 32;
}
--- a/sx1276/sx1276.h Tue May 16 17:51:21 2017 +0200
+++ b/sx1276/sx1276.h Wed May 17 15:40:13 2017 +0200
@@ -357,7 +357,7 @@
* @param [IN]: buffer Header pointer
* @param [IN]: size Header size
*/
- virtual void Send( uint8_t *buffer, uint8_t size, uint8_t *header = NULL, uint8_t hsize = 0);
+ virtual void Send(void *buffer, int16_t size, void *header = NULL, int16_t hsize = 0);
/*!
* @brief Sets the radio in sleep mode
@@ -435,7 +435,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 ) = 0;
+ virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0;
/*!
* @brief Reads multiple radio registers starting at address
@@ -444,7 +444,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 ) = 0;
+ virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0;
/*!
* @brief Writes the buffer contents to the SX1276 FIFO
@@ -452,7 +452,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 ) = 0;
+ virtual void WriteFifo( void *buffer, uint8_t size ) = 0;
/*!
* @brief Reads the contents of the SX1276 FIFO
@@ -460,7 +460,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 ) = 0;
+ virtual void ReadFifo( void *buffer, uint8_t size ) = 0;
/*!
* @brief Resets the SX1276
*/
