Browse Source

Подключил модуль. Портирую тесты.

TelenkovDmitry 10 months ago
parent
commit
a672078a79

+ 165 - 181
modules/lt8920/lt8920.cpp

@@ -4,6 +4,12 @@
 #include <stdio.h>
 
 
+#undef DBG
+#define DBG if(0)
+
+
+
+
 void LT8920::dump_register(uint8_t reg) 
 {
     uint16_t r = readRegister(reg);
@@ -78,273 +84,253 @@ void LT8920::begin()
 
 void LT8920::setChannel(uint8_t channel)
 {
-  _channel = channel;
-  writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK));
+    _channel = channel;
+    writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK));
 }
 
 uint8_t LT8920::getChannel()
 {
-  return _channel;
+    return _channel;
 }
 
 void LT8920::setCurrentControl(uint8_t power, uint8_t gain)
 {
-  writeRegister(R_CURRENT,
-                ((power << CURRENT_POWER_SHIFT) & CURRENT_POWER_MASK) |
-                ((gain << CURRENT_GAIN_SHIFT) & CURRENT_GAIN_MASK));
+    writeRegister(R_CURRENT,
+                 ((power << CURRENT_POWER_SHIFT) & CURRENT_POWER_MASK) |
+                 ((gain << CURRENT_GAIN_SHIFT) & CURRENT_GAIN_MASK));
 }
 
 bool LT8920::setDataRate(DataRate rate)
 {
-  uint16_t newValue;
-
-  switch (rate)
-  {
-    case LT8920_1MBPS:
-      newValue = DATARATE_1MBPS;
-      break;
-    case LT8920_250KBPS:
-      newValue = DATARATE_250KBPS;
-      break;
-    case LT8920_125KBPS:
-      newValue = DATARATE_125KBPS;
-      break;
-    case LT8920_62KBPS:
-      newValue = DATARATE_62KBPS;
-      break;
-    default:
-      return false;
-  }
-
-  writeRegister(R_DATARATE, newValue);
-  return ( (readRegister(R_DATARATE) & DATARATE_MASK) == (newValue & DATARATE_MASK));
+    uint16_t newValue;
+
+    switch (rate)
+    {
+        case LT8920_1MBPS:
+            newValue = DATARATE_1MBPS;
+        break;
+        case LT8920_250KBPS:
+            newValue = DATARATE_250KBPS;
+        break;
+        case LT8920_125KBPS:
+            newValue = DATARATE_125KBPS;
+        break;
+        case LT8920_62KBPS:
+            newValue = DATARATE_62KBPS;
+        break;
+        default:
+            return false;
+    }
+    
+    writeRegister(R_DATARATE, newValue);
+    
+    return ( (readRegister(R_DATARATE) & DATARATE_MASK) == (newValue & DATARATE_MASK));
 }
 
 LT8920::DataRate LT8920::getDataRate()
 {
-  uint16_t value = readRegister(R_DATARATE) & DATARATE_MASK;
-  switch (value)
-  {
-    case DATARATE_1MBPS:
-      return LT8920_1MBPS;
-    case DATARATE_250KBPS:
-      return LT8920_250KBPS;
-    case DATARATE_125KBPS:
-      return LT8920_125KBPS;
-    case DATARATE_62KBPS:
-      return LT8920_62KBPS;
-  }
+    uint16_t value = readRegister(R_DATARATE) & DATARATE_MASK;
+    
+    switch (value)
+    {
+        case DATARATE_1MBPS:
+            return LT8920_1MBPS;
+        case DATARATE_250KBPS:
+            return LT8920_250KBPS;
+        case DATARATE_125KBPS:
+            return LT8920_125KBPS;
+        case DATARATE_62KBPS:
+            return LT8920_62KBPS;
+        default : 
+            return LT8920_ERROR;
+    }
 }
 
 uint16_t LT8920::readRegister(uint8_t reg)
 {
     LT8920_CS_LOW;
-    SPI.transfer(REGISTER_READ | (REGISTER_MASK & reg));
-    uint8_t high = SPI.transfer(0x00);
-    uint8_t low = SPI.transfer(0x00);
+    
+    lt_spi_transfer_byte(REGISTER_READ | (REGISTER_MASK & reg));
+    uint8_t high = lt_spi_transfer_byte(0x00);
+    uint8_t low = lt_spi_transfer_byte(0x00);
     LT8920_CS_HIGH;
   
+    DBG printf("reg: %X = %X\r\n", reg, (high << 8 | low));
 
-  // Serial.print(reg);
-  // Serial.print(" = ");
-  // Serial.println(high << 8 | low);
-
-  return (high << 8 | low);
+    return (high << 8 | low);
 }
 
 uint8_t LT8920::writeRegister(uint8_t reg, uint16_t data)
 {
-  uint8_t high = data >> 8;
-  uint8_t low = data & 0xFF;
+    uint8_t high = data >> 8;
+    uint8_t low = data & 0xFF;
 
-  return writeRegister2(reg, high, low);
+    return writeRegister2(reg, high, low);
 }
 
 uint8_t LT8920::writeRegister2(uint8_t reg, uint8_t high, uint8_t low)
 {
-
   // char sbuf[32];
   // sprintf_P(sbuf, PSTR("%d => %02x%02x"), reg, high, low);
   // Serial.println(sbuf);
 
-
-  LT8920_CS_LOW;
-  uint8_t result = SPI.transfer(REGISTER_WRITE | (REGISTER_MASK & reg));
-  SPI.transfer(high);
-  SPI.transfer(low);
-
-  LT8920_CS_HIGH;
-  return result;
+    LT8920_CS_LOW;
+    uint8_t result = lt_spi_transfer_byte(REGISTER_WRITE | (REGISTER_MASK & reg));
+    lt_spi_transfer_byte(high);
+    lt_spi_transfer_byte(low);
+    
+    LT8920_CS_HIGH;
+    return result;
 }
 
 void LT8920::sleep()
 {
-  //set bit 14 on register 35.
-  writeRegister(35, readRegister(35) | _BV(14));
+    //set bit 14 on register 35.
+    writeRegister(35, readRegister(35) | _BV(14));
 }
 
 void LT8920::whatsUp(void)
 {
-  uint16_t mode = readRegister(R_CHANNEL);
-  
-#if 0  
-  print("\nTx_EN=");
-  println((mode & _BV(CHANNEL_TX_BIT)) != false);
-  print("Rx_EN=");
-  println((mode & _BV(CHANNEL_RX_BIT)) != false);
-  print("Channel=");
-  println(mode & CHANNEL_MASK);
-#endif
+    uint16_t mode = readRegister(R_CHANNEL);
   
-  //read the status register.
-  uint16_t state = readRegister(R_STATUS);
-
-  bool crc_error = state & _BV(15);
-  bool fec23_error = state & _BV(14);
-  uint8_t framer_st = (state & 0b0011111100000000) >> 8;
-  bool pkt_flag = state & _BV(6);
-  bool fifo_flag = state & _BV(5);
-
-#if 0  
-  stream.print("CRC=");
-  stream.println(crc_error);
-  stream.print("FEC=");
-  stream.println(fec23_error);
-  stream.print("FRAMER_ST=");
-  stream.println(framer_st);
-  stream.print("PKT=");
-  stream.println(pkt_flag);
-  stream.print("FIFO=");
-  stream.println(fifo_flag);
-#endif
+    DBG printf("Tx_EN = %u, Rx_EN = %u\r\n", (mode & _BV(CHANNEL_TX_BIT)), (mode & _BV(CHANNEL_RX_BIT)));
+    DBG printf("Channel = %u\r\n", (mode & CHANNEL_MASK));  
   
-  uint16_t fifo = readRegister(R_FIFO_CONTROL);
-#if 0
-  stream.print("FIFO_WR_PTR=");
-  stream.println((fifo >> 8) & 0b111111);
-  stream.print("FIFO_RD_PTR=");
-  stream.println(fifo & 0b111111);
-#endif  
+    //read the status register.
+    uint16_t state = readRegister(R_STATUS);
+
+    bool crc_error = state & _BV(15);
+    bool fec23_error = state & _BV(14);
+    uint8_t framer_st = (state & 0b0011111100000000) >> 8;
+    bool pkt_flag = state & _BV(6);
+    bool fifo_flag = state & _BV(5);
+
+    DBG printf("CRC = %u, FEC = %u, FRAMER_ST = %u, PKT = %u, FIFO = %u\r\n",
+               crc_error, fec23_error, framer_st, pkt_flag, fifo_flag);
+
+    uint16_t fifo = readRegister(R_FIFO_CONTROL);
+    
+    DBG printf("FIFO_WR_PTR = %X, FIFO_RD_PTR = %X\r\n", 
+               ((fifo >> 8) & 0b111111), (fifo & 0b111111));
 }
 
 bool LT8920::available()
 {
   //read the PKT_FLAG state; this can also be done with a hard wire.
+    if (LT8920_GET_PKT != 0) {
+        return true;
+    }
 
-  if (LT8920_GET_PKT != 0)
-  {
-    return true;
-  }
-
-  return false;
+    return false;
 }
 
 int LT8920::read(uint8_t *buffer, size_t maxBuffer)
 {
-  uint16_t value = readRegister(R_STATUS);
-  if (bitRead(value, STATUS_CRC_BIT) == 0)
-  {
-    //CRC ok
-
-    uint16_t data = readRegister(R_FIFO);
-    uint8_t packetSize = data >> 8;
-    if(maxBuffer < packetSize+1)
+    uint16_t value = readRegister(R_STATUS);
+    uint8_t pos = 0;
+    
+    if (bitRead(value, STATUS_CRC_BIT) == 0)
     {
-        //BUFFER TOO SMALL
-        return -2;
+        //CRC ok
+        uint16_t data = readRegister(R_FIFO);
+        uint8_t packetSize = data >> 8;
+        
+        if (maxBuffer < packetSize + 1) {
+            //BUFFER TOO SMALL
+            return -2;
+        }
+        
+        buffer[pos++] = (data & 0xFF);
+        
+        while (pos < packetSize)
+        {
+            data = readRegister(R_FIFO);
+            buffer[pos++] = data >> 8;
+            buffer[pos++] = data & 0xFF;
+        }
+
+        return packetSize;
     }
-
-    uint8_t pos;
-    buffer[pos++] = (data & 0xFF);
-    while (pos < packetSize)
-    {
-      data = readRegister(R_FIFO);
-      buffer[pos++] = data >> 8;
-      buffer[pos++] = data & 0xFF;
+    else {
+        //CRC error
+        return -1;
     }
-
-    return packetSize;
-  }
-  else
-  {
-    //CRC error
-    return -1;
-  }
 }
 
 void LT8920::startListening()
 {
-  writeRegister(R_CHANNEL, _channel & CHANNEL_MASK);   //turn off rx/tx
-  HAL_Delay(3);
-  writeRegister(R_FIFO_CONTROL, 0x0080);  //flush rx
-  writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK) | _BV(CHANNEL_RX_BIT));   //enable RX
-  HAL_Delay(5);
+    writeRegister(R_CHANNEL, _channel & CHANNEL_MASK);    // turn off rx/tx
+    HAL_Delay(3);
+    writeRegister(R_FIFO_CONTROL, 0x0080);  //flush rx
+    writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK) | _BV(CHANNEL_RX_BIT));   //enable RX
+    HAL_Delay(5);
 }
 
 /* set the BRCLK_SEL value */
 void LT8920::setClock(uint8_t clock)
 {
-  //register 32, bits 3:1.
-  uint16_t val = readRegister(35);
-  val &= 0b1111111111110001;
-  val |= ((clock & 0x07) << 1);;
+    //register 32, bits 3:1.
+    uint16_t val = readRegister(35);
+    val &= 0b1111111111110001;
+    val |= ((clock & 0x07) << 1);;
 
-  writeRegister(35, val);
+    writeRegister(35, val);
 }
 
 bool LT8920::sendPacket(uint8_t *data, size_t packetSize)
 {
-  if (packetSize < 1 || packetSize > 255)
-  {
-    return false;
-  }
+    if (packetSize < 1 || packetSize > 255)
+    {
+        return false;
+    }
 
-  writeRegister(R_CHANNEL, 0x0000);
-  writeRegister(R_FIFO_CONTROL, 0x8000);  //flush tx
+    writeRegister(R_CHANNEL, 0x0000);
+    writeRegister(R_FIFO_CONTROL, 0x8000);  //flush tx
 
-  //packets are sent in 16bit words, and the first word will be the packet size.
-  //start spitting out words until we are done.
+    // packets are sent in 16bit words, and the first word will be the packet size.
+    // start spitting out words until we are done.
 
-  uint8_t pos = 0;
-  writeRegister2(R_FIFO, packetSize, data[pos++]);
-  while (pos < packetSize)
-  {
-    uint8_t msb = data[pos++];
-    uint8_t lsb = data[pos++];
+    uint8_t pos = 0;
+    writeRegister2(R_FIFO, packetSize, data[pos++]);
+  
+    while (pos < packetSize)
+    {
+        uint8_t msb = data[pos++];
+        uint8_t lsb = data[pos++];
 
-    writeRegister2(R_FIFO, msb, lsb);
-  }
+        writeRegister2(R_FIFO, msb, lsb);
+    }
 
-  writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK) | _BV(CHANNEL_TX_BIT));   //enable TX
+    writeRegister(R_CHANNEL,  (_channel & CHANNEL_MASK) | _BV(CHANNEL_TX_BIT));   //enable TX
 
-  //Wait until the packet is sent.
-  while (LT8920_GET_PKT == 0)
-  {
-      //do nothing.
-  }
+    // Wait until the packet is sent.
+    while (LT8920_GET_PKT == 0)
+    {
+        //do nothing.
+    }
 
-  return true;
+    return true;
 }
 
 void LT8920::setSyncWord(uint64_t syncWord)
 {
-  writeRegister(R_SYNCWORD1, syncWord);
-  writeRegister(R_SYNCWORD2, syncWord >> 16);
-  writeRegister(R_SYNCWORD3, syncWord >> 32);
-  writeRegister(R_SYNCWORD4, syncWord >> 48);
+    writeRegister(R_SYNCWORD1, syncWord);
+    writeRegister(R_SYNCWORD2, syncWord >> 16);
+    writeRegister(R_SYNCWORD3, syncWord >> 32);
+    writeRegister(R_SYNCWORD4, syncWord >> 48);
 }
 
 void LT8920::setSyncWordLength(uint8_t option)
 {
-  option &= 0x03;
-  option <<= 11;
+    option &= 0x03;
+    option <<= 11;
 
-  writeRegister(32, (readRegister(32) & 0b0001100000000000) | option);
+    writeRegister(32, (readRegister(32) & 0b0001100000000000) | option);
 }
 
 uint8_t LT8920::getRSSI()
 {
-    //RSSI: 15:10
+    // RSSI: 15:10
     uint16_t value = readRegister(6);
 
     return (value >> 10);
@@ -352,6 +338,8 @@ uint8_t LT8920::getRSSI()
 
 void LT8920::scanRSSI(uint16_t *buffer, uint8_t start_channel, uint8_t num_channels)
 {
+    uint8_t pos = 0;
+    
     // writeRegister(R_CHANNEL, _BV(CHANNEL_RX_BIT));
     //
     // //add read mode.
@@ -365,16 +353,12 @@ void LT8920::scanRSSI(uint16_t *buffer, uint8_t start_channel, uint8_t num_chann
     writeRegister(43, (readRegister(43) & 0b0000000011111111) | ((start_channel & 0b1111111) << 8));
     writeRegister(43, (readRegister(43) & 0b0111111111111111) | _BV(15));
 
-    while (LT8920_GET_PKT == 0)
-    {
-    }
-
+    while (LT8920_GET_PKT == 0) {}
 
     //read the results.
-     uint8_t pos = 0;
-    while(pos < num_channels)
+    while (pos < num_channels)
     {
-      uint16_t data = readRegister(R_FIFO);
-      buffer[pos++] = data >> 8;
+        uint16_t data = readRegister(R_FIFO);
+        buffer[pos++] = data >> 8;
     }
 }

+ 4 - 1
modules/lt8920/lt8920.h

@@ -56,7 +56,8 @@ class LT8920
       LT8920_1MBPS,     /** default transmit rate */
       LT8920_250KBPS,   /** 250 Kpbs, only on lt8910 */
       LT8920_125KBPS,   /** 125 Kbps, only on lt8910 */
-      LT8920_62KBPS     /** 62 Kbps, only on lt8910 */
+      LT8920_62KBPS,     /** 62 Kbps, only on lt8910 */
+      LT8920_ERROR
     };
 
   private:
@@ -184,4 +185,6 @@ class LT8920
 
 #define _BV(bit) (1 << (bit))
 
+#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
+
 #endif

+ 48 - 0
modules/lt8920/lt8920_test.cpp

@@ -0,0 +1,48 @@
+#include "stm32l0xx_hal.h"
+#include "lt8920_test.h"
+#include "lt8920.h"
+#include "stm32l0xx_nucleo.h"
+#include <stdio.h>
+
+LT8920 lt;
+
+uint16_t wifi_Channels[] = {2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447,
+                            2452, 2457, 2462, 2467, 2472, 2484};
+ 
+uint16_t signals[32];
+char sbuf[64]; 
+ 
+ 
+//
+void lt_test_1(void)
+{
+    lt.begin();
+    lt.setCurrentControl(15, 15);  
+	//lt.setDataRate(LT8920::LT8920_1MBPS); 
+	lt.setChannel(0x06);
+}
+
+//
+void lt_scanner_test(void)
+{
+    printf("\033[2J"); // Очистить
+    printf("\033[H");  // Переместить курсор в левый верхний угол
+    
+    for(int i = 0; i < sizeof(wifi_Channels)/sizeof(uint16_t); i++)
+    {  
+        lt.scanRSSI(&signals[i], wifi_Channels[i]-2402, 1); 
+    }
+    
+    for(int i = 0; i < sizeof(wifi_Channels)/sizeof(uint16_t); i++)
+    {
+        sprintf(sbuf, "[%02d] %d = %04x ", i+1, wifi_Channels[i], signals[i]);
+        printf(sbuf);    
+        
+        for(int j =0 ; j < signals[i]/2; j++)
+        {
+            printf("#");
+        }
+        printf("\r\n");
+    }
+    HAL_Delay(250);
+}

+ 11 - 0
modules/lt8920/lt8920_test.h

@@ -0,0 +1,11 @@
+#ifndef __LT8920_TEST_H
+#define __LT8920_TEST_H
+
+
+//
+void lt_test_1(void);
+
+//
+void lt_scanner_test(void);
+
+#endif

+ 15 - 3
modules/lt8920/lt8920_trs.cpp

@@ -22,7 +22,7 @@ void lt_spi_init(void)
     __HAL_RCC_SPI2_CLK_ENABLE();
     
     SpiHandle.Instance               = SPI2;
-    SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
+    SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
     SpiHandle.Init.Direction         = SPI_DIRECTION_2LINES;
     SpiHandle.Init.CLKPhase          = SPI_PHASE_1EDGE;
     SpiHandle.Init.CLKPolarity       = SPI_POLARITY_HIGH;
@@ -35,6 +35,8 @@ void lt_spi_init(void)
     SpiHandle.Init.Mode = SPI_MODE_MASTER;
 
     HAL_SPI_Init(&SpiHandle);
+    
+    __HAL_SPI_ENABLE(&SpiHandle);
       
 }
 
@@ -49,14 +51,14 @@ void lt_gpio_init(void)
     GPIO_InitStruct.Pin       = GPIO_PIN_2;
     GPIO_InitStruct.Mode      = GPIO_MODE_OUTPUT_PP;
     GPIO_InitStruct.Pull      = GPIO_PULLUP;
-    GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH  ;
+    GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH;
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
     
     // LT8920 PKT pin PB12
     GPIO_InitStruct.Pin       = GPIO_PIN_12;
     GPIO_InitStruct.Mode      = GPIO_MODE_INPUT;
     GPIO_InitStruct.Pull      = GPIO_PULLUP;
-    GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH  ;
+    GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH;
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 }
 
@@ -93,6 +95,16 @@ void lt_spi_gpio_init(void)
     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 }
  
+//
+uint16_t lt_spi_transfer_byte(uint8_t byte)
+{
+    while (__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_TXE) != SET) {}
+    SpiHandle.Instance->DR = (uint16_t)byte;
+  
+    while (__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != SET) {}
+    return SpiHandle.Instance->DR;
+}
+
 
 // -------------------------------------------------------------------------- //
 

+ 3 - 0
modules/lt8920/lt8920_trs.h

@@ -22,6 +22,9 @@ void lt_gpio_init(void);
 //
 void lt_spi_gpio_init(void);
 
+//
+uint16_t lt_spi_transfer_byte(uint8_t byte);
+
 // -------------------------------------------------------------------------- //
 
 //

File diff suppressed because it is too large
+ 388 - 381
project/ewarm/lt8920.dep


+ 3 - 0
project/ewarm/lt8920.ewp

@@ -2297,6 +2297,9 @@
             <file>
                 <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920.cpp</name>
             </file>
+            <file>
+                <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920_test.cpp</name>
+            </file>
             <file>
                 <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920_trs.cpp</name>
             </file>

+ 3 - 0
project/ewarm/lt8920.ewt

@@ -2556,6 +2556,9 @@
             <file>
                 <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920.cpp</name>
             </file>
+            <file>
+                <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920_test.cpp</name>
+            </file>
             <file>
                 <name>$PROJ_DIR$\..\..\modules\lt8920\lt8920_trs.cpp</name>
             </file>

+ 21 - 22
project/project.ioc

@@ -8,7 +8,7 @@ Mcu.CPN=STM32L053R8T3
 Mcu.Family=STM32L0
 Mcu.IP0=NVIC
 Mcu.IP1=RCC
-Mcu.IP2=SPI1
+Mcu.IP2=SPI2
 Mcu.IP3=SYS
 Mcu.IP4=USART2
 Mcu.IPNb=5
@@ -16,20 +16,19 @@ Mcu.Name=STM32L053R(6-8)Tx
 Mcu.Package=LQFP64
 Mcu.Pin0=PC13
 Mcu.Pin1=PC14-OSC32_IN
-Mcu.Pin10=PA7
+Mcu.Pin10=PB15
 Mcu.Pin11=PA13
 Mcu.Pin12=PA14
-Mcu.Pin13=PB3
-Mcu.Pin14=VP_SYS_VS_Systick
+Mcu.Pin13=VP_SYS_VS_Systick
 Mcu.Pin2=PC15-OSC32_OUT
 Mcu.Pin3=PH0-OSC_IN
 Mcu.Pin4=PH1-OSC_OUT
 Mcu.Pin5=PA2
 Mcu.Pin6=PA3
-Mcu.Pin7=PA4
-Mcu.Pin8=PA5
-Mcu.Pin9=PA6
-Mcu.PinsNb=15
+Mcu.Pin7=PA5
+Mcu.Pin8=PB13
+Mcu.Pin9=PB14
+Mcu.PinsNb=14
 Mcu.ThirdPartyNb=0
 Mcu.UserConstants=
 Mcu.UserName=STM32L053R8Tx
@@ -61,18 +60,19 @@ PA3.GPIO_Label=USART_RX
 PA3.Locked=true
 PA3.Mode=Asynchronous
 PA3.Signal=USART2_RX
-PA4.Mode=NSS_Signal_Hard_Output
-PA4.Signal=SPI1_NSS
 PA5.GPIOParameters=GPIO_Label
 PA5.GPIO_Label=LD2 [Green Led]
 PA5.Locked=true
 PA5.Signal=GPIO_Output
-PA6.Mode=Full_Duplex_Master
-PA6.Signal=SPI1_MISO
-PA7.Mode=Full_Duplex_Master
-PA7.Signal=SPI1_MOSI
-PB3.Mode=Full_Duplex_Master
-PB3.Signal=SPI1_SCK
+PB13.Locked=true
+PB13.Mode=Full_Duplex_Master
+PB13.Signal=SPI2_SCK
+PB14.Locked=true
+PB14.Mode=Full_Duplex_Master
+PB14.Signal=SPI2_MISO
+PB15.Locked=true
+PB15.Mode=Full_Duplex_Master
+PB15.Signal=SPI2_MOSI
 PC13.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
 PC13.GPIO_Label=B1 [Blue PushButton]
 PC13.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
@@ -159,12 +159,11 @@ RCC.VCOOutputFreq_Value=64000000
 RCC.WatchDogFreq_Value=37000
 SH.GPXTI13.0=GPIO_EXTI13
 SH.GPXTI13.ConfNb=1
-SPI1.CalculateBaudRate=16.0 MBits/s
-SPI1.Direction=SPI_DIRECTION_2LINES
-SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,VirtualNSS
-SPI1.Mode=SPI_MODE_MASTER
-SPI1.VirtualNSS=VM_NSSHARD
-SPI1.VirtualType=VM_MASTER
+SPI2.CalculateBaudRate=16.0 MBits/s
+SPI2.Direction=SPI_DIRECTION_2LINES
+SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
+SPI2.Mode=SPI_MODE_MASTER
+SPI2.VirtualType=VM_MASTER
 USART2.IPParameters=VirtualMode-Asynchronous
 USART2.VirtualMode-Asynchronous=VM_ASYNC
 VP_SYS_VS_Systick.Mode=SysTick

+ 6 - 1
user/main.cpp

@@ -2,6 +2,7 @@
 #include "stm32l0xx_nucleo.h"
 #include "usart.h"
 #include "lt8920_trs.h"
+#include "lt8920_test.h"
 #include <stdio.h>
 
 void clock_hsi_init(void);
@@ -21,13 +22,17 @@ int main()
     usart_init();
     printf("Controller starting...\r\n");
     
+// -------------------------------------------------------------------------- //
+// RF module
     lt_init();
+    lt_test_1();
     
     while (1)
     {
         BSP_LED_Toggle(LED2);
+        lt_scanner_test();
         //lt_spi_test();
-        HAL_Delay(1000);
+        //HAL_Delay(250);
     }
 }
 

Some files were not shown because too many files changed in this diff