@@ -64,9 +64,6 @@ func ReadContexts(iocFile string, params []BridgeParamType) error {
6464 if err != nil {
6565 return err
6666 }
67- if mspName == "" {
68- return errors .New ("*_hal_msp.c not found" )
69- }
7067
7168 var cfgPath string
7269 cfgPath = filepath .Dir (workDir )
@@ -128,16 +125,17 @@ func writeMXdeviceH(contextMap map[string]map[string]string, srcFolder string, m
128125 if generatedAsPair != "true" {
129126 main := filepath .Join (srcFolderAbs , "main.c" )
130127 main = filepath .ToSlash (main )
131- fMain , err = os .Open (main )
132- if err != nil {
133- return err
134- }
135128
136- msp := filepath .Join (srcFolderAbs , mspName )
137- msp = filepath .ToSlash (msp )
138- fMsp , err = os .Open (msp )
139- if err != nil {
140- return err
129+ // In some cases main.c is not generated (e.g. ExternalLoader project)
130+ // In such cases main.c won't be parsed to get peripheral info for MX_Device.h
131+ fMain , _ = os .Open (main )
132+
133+ // In some cases *_hal_msp.c is not generated (e.g. no HAL peripherals selected, only LL)
134+ // In such cases *_hal_msp.c won't be parsed to get pin info for MX_Device.h
135+ if mspName != "" {
136+ msp := filepath .Join (srcFolderAbs , mspName )
137+ msp = filepath .ToSlash (msp )
138+ fMsp , _ = os .Open (msp )
141139 }
142140 }
143141 if fMain != nil {
@@ -767,7 +765,12 @@ func getPinConfiguration(fMsp *os.File, peripheral string, pin string, label str
767765
768766 pinNum := getDigitAtEnd (pin )
769767 gpioPin := "GPIO_PIN_" + pinNum
770- port := strings .Split (strings .Split (pin , "P" )[1 ], pinNum )[0 ]
768+ port := ""
769+ if strings .HasPrefix (pin , "P" ) {
770+ port = strings .Split (strings .Split (pin , "P" )[1 ], pinNum )[0 ]
771+ } else {
772+ port = strings .Split (pin , pinNum )[0 ]
773+ }
771774 gpioPort := "GPIO" + port
772775
773776 section := false
0 commit comments