Skip to content

Commit

Permalink
SoftRF: UAT978 build for TI's most recent CC13X2 family of RF ICs is …
Browse files Browse the repository at this point in the history
…doing good.
  • Loading branch information
lyusupov committed Apr 28, 2020
1 parent a3669ce commit 720807a
Show file tree
Hide file tree
Showing 27 changed files with 117 additions and 80 deletions.
3 changes: 2 additions & 1 deletion software/firmware/source/SoftRF/EEPROMHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#ifndef EEPROMHELPER_H
#define EEPROMHELPER_H

#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX) && !defined(__ASR6501__)
#if defined(ARDUINO) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2)
#include <EEPROM.h>
#endif /* ARDUINO */

Expand Down
9 changes: 7 additions & 2 deletions software/firmware/source/SoftRF/Platform_CC13XX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#if defined(ENERGIA_ARCH_CC13XX)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)

#include "SoCHelper.h"
#include "RFHelper.h"
#include "LEDHelper.h"
#include "SoundHelper.h"

#if defined(ENERGIA_ARCH_CC13XX)
#include <easylink/EasyLink.h>
#endif /* ENERGIA_ARCH_CC13XX */
#if defined(ENERGIA_ARCH_CC13X2)
#include <easylink/EasyLinkv2.h>
#endif /* ENERGIA_ARCH_CC13X2 */

// RFM95W pin mapping
lmic_pinmap lmic_pins = {
Expand Down Expand Up @@ -203,4 +208,4 @@ const SoC_ops_t CC13XX_ops = {
CC13XX_WDT_fini
};

#endif /* ENERGIA_ARCH_CC13XX */
#endif /* ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2 */
8 changes: 6 additions & 2 deletions software/firmware/source/SoftRF/Platform_CC13XX.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(ENERGIA_ARCH_CC13XX)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)

#ifndef PLATFORM_CC13XX_H
#define PLATFORM_CC13XX_H

#include "IPAddress.h"
#include <WS2812.h>

#if defined(ENERGIA_ARCH_CC13X2)
extern size_t strnlen (const char *, size_t);
#endif /* ENERGIA_ARCH_CC13X2 */

/* Maximum of tracked flying objects is now SoC-specific constant */
#define MAX_TRACKING_OBJECTS 8

Expand Down Expand Up @@ -74,4 +78,4 @@ extern uint8_t LEDs[][3];

#endif /* PLATFORM_CC13XX_H */

#endif /* ENERGIA_ARCH_CC13XX */
#endif /* ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2 */
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/SoCHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ byte SoC_setup()
SoC = &ESP32_ops;
#elif defined(RASPBERRY_PI)
SoC = &RPi_ops;
#elif defined(ENERGIA_ARCH_CC13XX)
#elif defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
SoC = &CC13XX_ops;
#elif defined(ARDUINO_ARCH_STM32)
SoC = &STM32_ops;
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/SoCHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern const SoC_ops_t ESP32_ops;
#if defined(RASPBERRY_PI)
extern const SoC_ops_t RPi_ops;
#endif
#if defined(ENERGIA_ARCH_CC13XX)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
extern const SoC_ops_t CC13XX_ops;
#endif
#if defined(ARDUINO_ARCH_STM32)
Expand Down
4 changes: 2 additions & 2 deletions software/firmware/source/SoftRF/SoftRF.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <Arduino.h>
#endif /* ARDUINO */

#if defined(ENERGIA_ARCH_CC13XX)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
#include <TimeLib.h>
#endif /* ENERGIA_ARCH_CC13XX */
#endif /* ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2 */

#if defined(RASPBERRY_PI)
#include <raspi/raspi.h>
Expand Down
6 changes: 4 additions & 2 deletions software/firmware/source/SoftRF/WebHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

#include <TinyGPS++.h>

#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX) && !defined(__ASR6501__)
#if defined(ARDUINO) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2)
#include <WiFiClient.h>
#endif /* ARDUINO */

Expand All @@ -44,7 +45,8 @@ extern uint32_t tx_packets_counter, rx_packets_counter;
//extern byte TxBuffer[PKT_SIZE];
extern String TxDataTemplate;

#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX) && !defined(__ASR6501__)
#if defined(ARDUINO) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2)
extern WiFiClient client;
#endif /* ARDUINO */

Expand Down
6 changes: 4 additions & 2 deletions software/firmware/source/SoftRF/WiFiHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#ifndef WIFIHELPER_H
#define WIFIHELPER_H

#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX) && !defined(__ASR6501__)
#if defined(ARDUINO) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2)
#include <WiFiUdp.h>
#endif

Expand All @@ -42,7 +43,8 @@ void Raw_Transmit_UDP(void);
void WiFi_fini(void);

extern String host_name;
#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX) && !defined(__ASR6501__)
#if defined(ARDUINO) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2)
extern WiFiUDP Uni_Udp;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#include "WProgram.h"
#endif

#if !(defined(ESP8266) || defined(ESP32) || defined(ENERGIA_ARCH_CC13XX) || \
defined(ARDUINO_ARCH_STM32) || defined(__ASR6501__))
#if !(defined(ESP8266) || defined(ESP32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32) || defined(__ASR6501__))
#include <Adafruit_Sensor.h>
#endif

Expand Down
31 changes: 20 additions & 11 deletions software/firmware/source/libraries/CRC/lib_crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <pgmspace.h>
#endif

#if defined(ENERGIA_ARCH_CC13XX) || defined(ARDUINO_ARCH_STM32)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32)
#include <avr/pgmspace.h>
#endif

Expand Down Expand Up @@ -106,8 +107,9 @@ static unsigned short crc_tabdnp[256];
static unsigned short crc_tabkermit[256];
#endif

#if !defined(ESP8266) && !defined(ENERGIA_ARCH_CC13XX) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32)
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32)
static unsigned short crc_tabccitt[256];
#else
static const unsigned short crc_tabccitt[256] PROGMEM = {
Expand Down Expand Up @@ -183,8 +185,9 @@ unsigned short update_crc_ccitt( unsigned short crc, char c ) {
if ( ! crc_tabccitt_init ) init_crcccitt_tab();

tmp = (crc >> 8) ^ short_c;
#if defined(ESP8266) || defined(ENERGIA_ARCH_CC13XX) || \
defined(__ASR6501__) || defined(ARDUINO_ARCH_STM32)
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32)
crc = (crc << 8) ^ pgm_read_word(&crc_tabccitt[tmp]);
#else
crc = (crc << 8) ^ crc_tabccitt[tmp];
Expand Down Expand Up @@ -486,8 +489,9 @@ static void init_crc32_tab( void ) {

static void init_crcccitt_tab( void ) {

#if !defined(ESP8266) && !defined(ENERGIA_ARCH_CC13XX) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32)
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32)
int i, j;
unsigned short crc, c;

Expand Down Expand Up @@ -521,8 +525,9 @@ unsigned short update_crc_gdl90( unsigned short crc, char c ) {
if ( ! crc_tabccitt_init ) init_crcccitt_tab();

tmp = (crc >> 8) ;
#if defined(ESP8266) || defined(ENERGIA_ARCH_CC13XX) || \
defined(__ASR6501__) || defined(ARDUINO_ARCH_STM32)
#if !defined(ESP8266) && !defined(__ASR6501__) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(ARDUINO_ARCH_STM32)
crc = pgm_read_word(&crc_tabccitt[tmp]) ^ (crc << 8) ^ short_c;
#else
crc = crc_tabccitt[tmp] ^ (crc << 8) ^ short_c;
Expand All @@ -540,7 +545,9 @@ unsigned short update_crc_gdl90( unsigned short crc, char c ) {
*/

static const unsigned char crc8_table[256]
#if defined(ESP8266) || defined(ESP32) || defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32)
PROGMEM
#endif
= {
Expand Down Expand Up @@ -575,7 +582,9 @@ void update_crc8(unsigned char *crc, unsigned char m)
* resultant crc obtained by appending m to the byte array
*/
{
#if defined(ESP8266) || defined(ESP32) || defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32)
*crc = pgm_read_byte(&crc8_table[(*crc) ^ m]);
#else
*crc = crc8_table[(*crc) ^ m];
Expand Down
14 changes: 9 additions & 5 deletions software/firmware/source/libraries/OGN/ldpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <math.h>
#endif

#if defined(__AVR__) || defined(ENERGIA_ARCH_CC13XX)
#if defined(__AVR__) || defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
#include <avr/pgmspace.h>
#endif

Expand All @@ -22,7 +22,8 @@
// every row represents a parity check to be performed on the received codeword
static const uint32_t LDPC_ParityCheck_n208k160[48][7]
#if defined(__AVR__) || defined(ESP8266) || defined(ESP32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(__ASR6501__)
PROGMEM
#endif
= { // parity check vectors: 48 vectors for 48 parity checks
Expand Down Expand Up @@ -148,7 +149,8 @@ PROGMEM
// every row represents the generator for a parity bit
static const uint32_t LDPC_ParityGen_n208k160[48][5]
#if defined(__AVR__) || defined(ESP8266) || defined(ESP32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(__ASR6501__)
PROGMEM
#endif
= { // Parity bits generator: 48 vectors to generate 48 parity bits
Expand Down Expand Up @@ -694,7 +696,8 @@ static void LDPC_Encode(const uint32_t *Data, uint32_t *Parity, uint8_t DataWord
for(uint8_t Row=0; Row<Checks; Row++)
{ uint8_t Count=0;
for(uint8_t Idx=0; Idx<DataWords; Idx++)
#if defined(ESP8266) || defined(ESP32) || defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
{ Count+=Count1s(Data[Idx] & (uint32_t) pgm_read_dword(Gen+Idx)); }
#else
{ Count+=Count1s(Data[Idx]&Gen[Idx]); }
Expand Down Expand Up @@ -735,7 +738,8 @@ uint8_t LDPC_Check(const uint8_t *Data) // 20 data bytes followed by 6 parity by
{ uint8_t Count=0;
const uint8_t *Check = (uint8_t *)LDPC_ParityCheck_n208k160[Row];
for(uint8_t Idx=0; Idx<26; Idx++)
#if defined(ESP8266) || defined(ESP32) || defined(ENERGIA_ARCH_CC13XX) || defined(__ASR6501__)
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
{ uint8_t And = Data[Idx]&pgm_read_byte(Check+Idx); Count+=Count1s(And); }
#else
{ uint8_t And = Data[Idx]&Check[Idx]; Count+=Count1s(And); }
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/libraries/OGN/ldpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdint.h>
#include <stdlib.h>

#if defined(__ASR6501__)
#if defined(__ASR6501__) || defined(ENERGIA_ARCH_CC13X2)
#undef min
#undef max
#endif
Expand Down
3 changes: 2 additions & 1 deletion software/firmware/source/libraries/OGN/manchester.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef __MANCHESTER_H__
#define __MANCHESTER_H__

#if defined(__AVR__) || defined(ENERGIA_ARCH_CC13XX) || defined(ARDUINO_ARCH_STM32)
#if defined(__AVR__) || defined(ARDUINO_ARCH_STM32) || \
defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)
#include <avr/pgmspace.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/libraries/WS2812/src/WS2812.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define SPIDIV 3 // 16 MHz/2 gives 125 ns for each on bit in byte
#define SPILONG 0b00001111 // 750 ns (acceptable "on" range 550 to 850 ns)
#define SPISHORT 0b00000011 // 375 ns (acceptable "on" range 200 to 500 ns)
#elif defined(BOARD_CC1310_LAUNCHXL)
#elif defined(BOARD_CC1310_LAUNCHXL) || defined(BOARD_CC1352R1_LAUNCHXL)
#define SPIDIV 3 // 16 MHz/2 gives 125 ns for each on bit in byte
#define SPILONG 0b00001111 // 750 ns (acceptable "on" range 550 to 850 ns)
#define SPISHORT 0b00000011 // 375 ns (acceptable "on" range 200 to 500 ns)
Expand Down
12 changes: 8 additions & 4 deletions software/firmware/source/libraries/adsb_encoder/adsb_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@

#define MODES_GENERATOR_POLY 0xfff409U

#if !defined(ESP8266) && !defined(ESP32) && !defined(ENERGIA_ARCH_CC13XX) && \
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32)
static unsigned int crc_table[256];
#else
#if defined(ESP8266) || defined(ESP32) || defined(__ASR6501__)
#include <pgmspace.h>
#endif

#if defined(ENERGIA_ARCH_CC13XX) || defined(ARDUINO_ARCH_STM32)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \
defined(ARDUINO_ARCH_STM32)
#include <avr/pgmspace.h>
#endif

Expand Down Expand Up @@ -71,7 +73,8 @@ unsigned int modes_crc(unsigned char *buf, size_t len)
unsigned int rem = 0;
size_t i;
for (rem = 0, i = len; i > 0; --i) {
#if !defined(ESP8266) && !defined(ESP32) && !defined(ENERGIA_ARCH_CC13XX) && \
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32)
rem = ((rem & 0x00ffff) << 8) ^ crc_table[*buf++ ^ ((rem & 0xff0000) >> 16)];
#else
Expand Down Expand Up @@ -628,7 +631,8 @@ frame_data_t make_velocity_frame(unsigned int addr,

int modescrc_module_init()
{
#if !defined(ESP8266) && !defined(ESP32) && !defined(ENERGIA_ARCH_CC13XX) && \
#if !defined(ESP8266) && !defined(ESP32) && \
!defined(ENERGIA_ARCH_CC13XX) && !defined(ENERGIA_ARCH_CC13X2) && \
!defined(__ASR6501__) && !defined(ARDUINO_ARCH_STM32)
int i;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined(ENERGIA_ARCH_CC13XX)
#if defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2)

#ifndef CC13XX_H
#define CC13XX_H
Expand All @@ -23,4 +23,4 @@ class SPISettings {
#endif /* __cplusplus */

#endif // CC13XX_H
#endif // ENERGIA_ARCH_CC13XX
#endif // ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2
Loading

0 comments on commit 720807a

Please sign in to comment.