Browse Source

small progress

Juraj Ďuďák 9 months ago
parent
commit
7d7fe8bb30
8 changed files with 35 additions and 12 deletions
  1. 2 2
      .cproject
  2. 1 0
      Core/Inc/app_imu.h
  3. 5 1
      Core/Src/app_imu.cpp
  4. 8 1
      Core/Src/stm32l0xx_hal_msp.c
  5. 1 1
      Modules/icm20948
  6. 2 0
      baModule-slave Debug.launch
  7. 3 1
      baModule-slave.ioc
  8. 13 6
      test/app.py

+ 2 - 2
.cproject

@@ -158,14 +158,14 @@
 							<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1623387497" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
 								<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.1314201316" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
 								<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.999331844" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
-								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.1928939775" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" valueType="includePath">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.1928939775" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
 									<listOptionValue builtIn="false" value="../Core/Inc"/>
 									<listOptionValue builtIn="false" value="../Drivers/STM32L0xx_HAL_Driver/Inc"/>
 									<listOptionValue builtIn="false" value="../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy"/>
 									<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
 									<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
 								</option>
-								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.1086513445" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" valueType="definedSymbols">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.1086513445" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
 									<listOptionValue builtIn="false" value="STM32L082xx"/>
 								</option>

+ 1 - 0
Core/Inc/app_imu.h

@@ -32,6 +32,7 @@ int32_t mcu_spi_getParam(uint8_t sensor_index, nBus_param_t param);
 uint8_t mcu_spi_hasParam(uint8_t sensor_index, nBus_param_t param);
 nBus_statusType_t mcu_spi_setParam(uint8_t sensor_index, nBus_param_t param, int32_t value);
 void mcu_spi_readData(void);
+uint8_t mcu_spi_deviceReady();
 /**
  * Run calibration procedure.
  * @param subslaveIndex index of sublave (specific sensor) to run calibration procedure. Can be: 0 - all sensors, 1, 2 - sensor index

+ 5 - 1
Core/Src/app_imu.cpp

@@ -29,7 +29,7 @@ nBusAppInterface_t mcu_spi_driver = {
 	  mcu_spi_calibrate,
 	  NULL, //getSensorFormat
 	  NULL, //find
-	  NULL //deviceReady
+	  mcu_spi_deviceReady
 };
 
 
@@ -400,6 +400,10 @@ nBus_statusType_t mcu_spi_calibrate(uint8_t subslaveIndex){
 	return success;
 }
 
+uint8_t mcu_spi_deviceReady()
+{
+    return 1;
+}
 /*
 uint8_t mcu_spi_store(void){
 	return 0;

+ 8 - 1
Core/Src/stm32l0xx_hal_msp.c

@@ -338,13 +338,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
     PA10     ------> USART1_RX
     PA12     ------> USART1_DE
     */
-    GPIO_InitStruct.Pin = VCP_TX_Pin|VCP_RX_Pin|GPIO_PIN_12;
+    GPIO_InitStruct.Pin = VCP_TX_Pin|GPIO_PIN_12;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
     GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
+    GPIO_InitStruct.Pin = VCP_RX_Pin;
+    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+    GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
+    HAL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct);
+
     /* USART1 DMA Init */
     /* USART1_RX Init */
     hdma_usart1_rx.Instance = DMA1_Channel3;

+ 1 - 1
Modules/icm20948

@@ -1 +1 @@
-Subproject commit 186ec7200fedb8aa18ebf7b4d7b9b2f8edd59600
+Subproject commit c951f5d2d407d56f7b41c139f68843c5b9c676d7

+ 2 - 0
baModule-slave Debug.launch

@@ -42,6 +42,7 @@
     <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
     <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
     <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
     <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
     <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
     <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
@@ -79,5 +80,6 @@
     <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
         <listEntry value="4"/>
     </listAttribute>
+    <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
     <stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
 </launchConfiguration>

+ 3 - 1
baModule-slave.ioc

@@ -115,8 +115,9 @@ PA0.Mode=IN0
 PA0.Signal=ADC_IN0
 PA1.Mode=IN1
 PA1.Signal=ADC_IN1
-PA10.GPIOParameters=GPIO_Label
+PA10.GPIOParameters=GPIO_PuPd,GPIO_Label
 PA10.GPIO_Label=VCP_RX
+PA10.GPIO_PuPd=GPIO_PULLUP
 PA10.Mode=Asynchronous
 PA10.Signal=USART1_RX
 PA11.Mode=Full_Duplex_Master
@@ -278,3 +279,4 @@ VP_SYS_VS_Systick.Signal=SYS_VS_Systick
 VP_TIM21_VS_ClockSourceINT.Mode=Internal
 VP_TIM21_VS_ClockSourceINT.Signal=TIM21_VS_ClockSourceINT
 board=custom
+isbadioc=false

+ 13 - 6
test/app.py

@@ -18,7 +18,7 @@ if __name__ == "__main__":
     nbus = NbusSystem(False)
     s1_adr = 5
     s2_adr = 6
-    adrs = [s1_adr, s2_adr]
+    adrs = [s1_adr]
 
     foundSlaves = {}
     for adr in adrs:
@@ -78,17 +78,24 @@ if __name__ == "__main__":
     for adr in adrs:
         data_acc[adr] = []
     print(data_acc)
-    for i in range(64):
+    start = time.time()
+    num = 56
+    for i in range(num):
         for adr in adrs:
             acc = nbus.get_slave(adr).cmd_sensor_get_data_IMU(1)
-            # gyr = nbus.get_slave(adr).cmd_sensor_get_data_IMU(2)
+            #gyr = nbus.get_slave(adr).cmd_sensor_get_data_IMU(2)
             data_acc[adr].append(acc)
-            # print(acc)
+            #print(gyr)
         print(".", end=" ")
+    stop = time.time() - start
+    print(f"t={stop}")
+    print(f"datarate={num/stop} mer/s")
+    nbus.cmd_stop()
     nbus.cmd_stop()
     show_data(data_acc)
-
-    # sys.exit()
+    nbus.cmd_stop()
+    nbus.finish()
+    sys.exit()
 
     for adr in adrs:
         for i in range(pocet[adr]):