Переглянути джерело

Исправлены ошибки с размерностью серийника, работой пинов питания и обработкой команд требующих ответов (добавлен символ переноса строки \n).

ChStepan 5 місяців тому
батько
коміт
6b910ff868

+ 3 - 4
App/nfm/nfm_base.c

@@ -36,11 +36,10 @@ const static char manufacturerId[] =  "CMT";
 static char g_firmwareId[16] = "0.1/01";
 
 // NFM model name
-static char g_modelName[16] = "MK207-04H";
+static char g_modelName[16] = "R0467";
 
 // Serial Number String
-static char g_serialNumber[9] = "00000001";
-
+static char g_serialNumber[9] = "25230066";
 // NFM Connectors descriptions
 const static char * const aConnectorsNames[] =
 {
@@ -1035,7 +1034,7 @@ static void private_ClassInit()
     NFMClassExtended->private.properties.modelProfile = NULL;
     NFMClassExtended->private.properties.memProfile = NULL;
 
-    NFMClassExtended->public.properties.modelName = NULL;
+    NFMClassExtended->public.properties.modelName = g_modelName;
     NFMClassExtended->public.properties.firmwareId = g_firmwareId;
     
     // prepare firmware ID string

+ 1 - 1
App/nfm/nfm_base_ECalUnit.h

@@ -23,7 +23,7 @@
     struct TEcalHeader 
     {
         uint8_t  Reserved1[64];
-        uint8_t  SN[10];           // ASCII (without PSN)
+        uint8_t  SN[8];           // ASCII (without PSN)
         uint16_t DeviceID;        // see eDeviceId_t
         uint8_t  Reserved2[48];
     };

+ 1 - 1
App/nfm/nfm_base_model.c

@@ -26,7 +26,7 @@ const sNFMModel_t aNFMModels[] =
       },
       
       { .deviceId  = eModel_PAK_LEMZ,
-        .modelName = "MK207-04H",
+        .modelName = "R0467",
         .nfProfile = &nf_profile_PAK_LEMZ,
         .memProfile = &memProfile_SW
       },      

+ 1 - 1
App/nfm/nfm_base_model.h

@@ -28,7 +28,7 @@
        eModel_SWB_16 = 21,                   // PE2P16Ta
        eModel_SWB_16M = 22,                  // ME216-18A 
        eModel_SWB_8M = 23,                   // ME208-18A
-       eModel_PAK_LEMZ = 24,                 // MK207-04H (PAK-LEMZ)
+       eModel_PAK_LEMZ = 24,                 // R0467 (PAK-LEMZ)
        eModel_undefined = 255,
     }
     eNFMModel_t;

+ 3 - 2
App/scpi/CommandHandlers/idn.c

@@ -69,11 +69,12 @@ static const struct fFSeqEntry_t * fsqf_CommandHandlerIDN( const struct fFSeqEnt
                  memset( common_ctx->tempBuffer, 0, sizeof(common_ctx->tempBuffer) );
 
                  // first call: prepare buffer
-                 _snprintf( common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), "%s,%s,%s,%s", 
+                 _snprintf( common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), "%s,%s,%s,%s""%s", 
                                    NFMClass->properties.manufacturerId, 
                                    NFMClass->properties.modelName, 
                                    NFMClass->properties.serialNumber, 
-                                   NFMClass->properties.firmwareId );
+                                   NFMClass->properties.firmwareId,
+                                   "\n" );
 
              }
              

+ 5 - 5
App/scpi/CommandHandlers/power_switch.c

@@ -26,7 +26,7 @@ const uint8_t fsqvbl_CommandHandlerMeasStop   = 3;  // MEAS:STOP
 const uint8_t fsqvbl_CommandHandlerMeasCont   = 4;  // MEAS:CONTinue
 const uint8_t fsqvbl_CommandHandlerMeasMode   = 5;  // MEAS:MODE
 
-static uint16_t sw_cmd_reg = 0x0000;
+static uint16_t sw_cmd_reg = 0xc000;
 
 #include "app/scpi/commandHandlers/power_switch.h"
 #include "app/nfm/nfm_base.h"
@@ -82,8 +82,8 @@ uint16_t set_bit(uint16_t cmd_register, uint16_t SW_Number, uint16_t SW_State) {
   case 6: {bit_position = 4;} break;
   case 7: {bit_position = 12;} break;
   case 8: {bit_position = 13;} break;
-  case 9: {bit_position = 14;} break;
-  case 10: {bit_position = 15;} break;
+  case 9: {bit_position = 14; SW_State =~SW_State;} break;
+  case 10: {bit_position = 15; SW_State =~SW_State;} break;
   }
 
   if (SW_Number == 4)
@@ -159,10 +159,10 @@ static const struct fFSeqEntry_t * fsqf_CommandHandlerCtrl_Switch_Group( const s
              // @idx - current position of the source data to be outputed
              if( common_ctx->MeasAndSwitch.idx == 0 ) // first reading
              {
-                 size_t length = 0;                 
+                 size_t length = 0;                
                  if( common_ctx->handler_ctx == &fsqvbl_CommandHandlerSwCtrl )
                  {
-                     length = _snprintf( common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), "%d", sw_cmd_reg);
+                   length = _snprintf( common_ctx->tempBuffer, sizeof(common_ctx->tempBuffer), "%d""%s", (sw_cmd_reg^49152), "\n" /*invert back bits 15 and 14 to keep valid response despite inversion in 'set_bit' procedure*/);
                  }
                  else if( common_ctx->handler_ctx == &fsqvbl_CommandHandlerMeasStart )
                  {

+ 7 - 4
App/scpi/CommandHandlers/scpi_service.c

@@ -15,7 +15,7 @@ const uint8_t fsqvbl_CommandHandlerServiceReboot = 4;        // SERVICE:REBOOT
 // Supported arguments: 1=CHARACTER
 DECLARE_SCPI_ARGS_C( eScpiArg_Numeric );
 
-DECLARE_ARGUMENT_NUMERIC_VALUES_I32(AllowedValues_ServiceState, 0, 1);
+DECLARE_ARGUMENT_NUMERIC_VALUES_I32(AllowedValues_ServiceState, 0, 9999999999);
 DECLARE_ARGUMENT_NUMERIC_VALUES_I32(AllowedValues_Serial, 0, 99999999);
 DECLARE_ARGUMENT_NUMERIC_VALUES_I32(AllowedValues_Model, 0, 255);
 
@@ -85,7 +85,10 @@ static const struct fFSeqEntry_t * fsqf_CommandHandlerService( const struct fFSe
                    // process first argument (switch state)
                    const sNumericEntry_t * ne = SCPI_PROCESS_ARGUMENT_NUMERIC(common_ctx, &AllowedValues_ServiceState, 0);
                    if( ScpiNumericSuccess != ne->error ) break;
-                   NFMClass->properties.isServiceMode = ne->Value.demicalInteger;
+                   if (ne->Value.demicalInteger == 65534 || ne->Value.demicalInteger == 0) 
+                   {
+                      NFMClass->properties.isServiceMode = ne->Value.demicalInteger;
+                   }
                }
                
                if(NFMClass->properties.isServiceMode)
@@ -100,12 +103,12 @@ static const struct fFSeqEntry_t * fsqf_CommandHandlerService( const struct fFSe
                        if(NFMClass->methods.xMemoryProtection.check())
                            NFMClass->methods.xMemoryProtection.disable();
                        
-                       char serial[10];
+                       char serial[8];
                        memset(&serial, 0x30, sizeof(serial));
                        
                        int numberOfDigits = common_ctx->argTokens[0].stail - common_ctx->argTokens[0].shead;
                        const char* symbol = common_ctx->argTokens[0].stail - 1; // also skip \n
-                       char* serialLastSymb = &serial[9];
+                       char* serialLastSymb = &serial[7];
                        
                        while(numberOfDigits--)
                            *serialLastSymb-- = *symbol--;

+ 1 - 1
App/usb/usb_config.h

@@ -16,7 +16,7 @@
 // Device Descriptor:
 #define USB_VID              0x2226  // 0x2226
 #define USB_PID_VENDOR       0x0054  // 0x0054
-#define USB_PID_USBTMC       0x0081
+#define USB_PID_USBTMC       0x0080
 #define USB_PID_DEBUG        0xFFFC  // 0xFFFC LibUsb debug
 #define USBD_MSOS_VENDOR     0x21
 

+ 2 - 0
Core/config_pins.h

@@ -69,11 +69,13 @@
   // Power management Pin
   #define CONFIG_PIN__INPTRG                         GPIO_PIN_8
   #define CONFIG_PIN__INPTRG_1                       GPIO_PIN_9
+  #define CONFIG_PIN__5VRF_EN                        GPIO_PIN_3
   #define CONFIG_PIN__EXT_REG_MR                     GPIO_PIN_8
   #define CONFIG_PIN__INPTRG_EN                      GPIO_PIN_10
 
   #define CONFIG_PORT__INPTRG                        GPIOA
   #define CONFIG_PORT__INPTRG_1                      GPIOA
+  #define CONFIG_PORT__5VRF_EN                       GPIOA 
   #define CONFIG_PORT__EXT_REG_MR                    GPIOA   
   #define CONFIG_PORT__INPTRG_EN                     GPIOA
   #define CONFIG_ADC_CHANNEL_POWER                   ADC_CHANNEL_1

+ 11 - 4
Drivers/power_management/power_management.c

@@ -12,6 +12,7 @@ static void INPTRG( bool state );
 static void INPTRG_1( bool state );
 static void INPTRG_EN( bool state );
 static void EXT_REG_MR( bool state );
+static void VRF_EN_5( bool state );
  
  const PM_Handle_t PMHandle = {
 
@@ -20,7 +21,8 @@ static void EXT_REG_MR( bool state );
     INPTRG,
     INPTRG_1,
     INPTRG_EN,
-    EXT_REG_MR
+    EXT_REG_MR,
+    VRF_EN_5
  };
 
 static inline void INPTRG( bool state )
@@ -42,6 +44,11 @@ static inline void EXT_REG_MR( bool state )
 {
     HAL_GPIO_WritePin( CONFIG_PORT__EXT_REG_MR, CONFIG_PIN__EXT_REG_MR, (state)?GPIO_PIN_SET:GPIO_PIN_RESET );
 }
+
+static inline void VRF_EN_5( bool state )
+{
+    HAL_GPIO_WritePin( CONFIG_PORT__5VRF_EN, CONFIG_PIN__5VRF_EN, (state)?GPIO_PIN_SET:GPIO_PIN_RESET );
+}
  
  static bool PM_Init()
  {
@@ -55,13 +62,13 @@ static inline void EXT_REG_MR( bool state )
    HAL_GPIO_Init(CONFIG_PORT__INPTRG, &GPIO_CTRL);
    
    GPIO_InitTypeDef GPIO_CTRL_PWR = {0};
-   GPIO_CTRL_PWR.Pin = CONFIG_PIN__EXT_REG_MR | CONFIG_PIN__INPTRG_EN; 
+   GPIO_CTRL_PWR.Pin = CONFIG_PIN__5VRF_EN | CONFIG_PIN__EXT_REG_MR | CONFIG_PIN__INPTRG_EN; 
    GPIO_CTRL_PWR.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_CTRL_PWR.Pull = GPIO_PULLUP;
    GPIO_CTRL_PWR.Speed = GPIO_SPEED_FREQ_MEDIUM;        
-   HAL_GPIO_Init(CONFIG_PORT__EXT_REG_MR, &GPIO_CTRL_PWR);
+   HAL_GPIO_Init(CONFIG_PORT__5VRF_EN, &GPIO_CTRL_PWR);
    
-   //VRF_EN_5(false); // Âûêëþ÷àåì ïèòàíèå íà ïëàòó óïðàâëåíèÿ (FPGA)
+   VRF_EN_5(true); // Âêëþ÷àåì ïèòàíèå íà ïëàòó óïðàâëåíèÿ (FPGA)
    INPTRG_EN(true); // Çàïðåò òðèããåðà îò VNA
    EXT_REG_MR(false);  // PowerUP with active RESET signal on external shift REG
    EI();

+ 1 - 0
Drivers/power_management/power_management.h

@@ -12,6 +12,7 @@
       void (*INPTRG_1)( bool state );
       void (*INPTRG_EN)( bool state );
       void (*EXT_REG_MR)( bool state );
+      void (*VRF_EN_5)( bool state );
   }
   PM_Handle_t;