def onLoad(state): # Prevent changed properties from enabling parent peripheral try: hal.registerDeviceOverride(hal.OVERRIDE_PERIPHERAL_AUTO_ENABLE, True) except: # Fall back to misspelled version of the function argument try: hal.registerDeviceOverride(hal.OVERRIDE_PERIPHRAL_AUTO_ENABLE, True) except: pass available_modules = Metadata.get_available_modules_for_family() if PROFILE: start = time.time() familyobj = dep.Family(state.device.name) modules = [] module_instance = ACMP_behavior.ACMP('ACMP0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('ACMP0', module_instance) modules.append(module_instance) module_instance = ACMP_behavior.ACMP('ACMP1') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('ACMP1', module_instance) modules.append(module_instance) module_instance = ADC_behavior.ADC('ADC0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('ADC0', module_instance) modules.append(module_instance) module_instance = ANTDIV_behavior.ANTDIV('ANTDIV') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('ANTDIV', module_instance) modules.append(module_instance) module_instance = BATTERYMON_behavior.BATTERYMON('BATTERYMON') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('BATTERYMON', module_instance) modules.append(module_instance) module_instance = BTL_BUTTON_behavior.BTL_BUTTON('BTL_BUTTON') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('BTL_BUTTON', module_instance) modules.append(module_instance) module_instance = BULBPWM_behavior.BULBPWM('BULBPWM') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('BULBPWM', module_instance) modules.append(module_instance) module_instance = BULBPWM_COLOR_behavior.BULBPWM_COLOR('BULBPWM_COLOR') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('BULBPWM_COLOR', module_instance) modules.append(module_instance) module_instance = BUTTON_behavior.BUTTON('BUTTON') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('BUTTON', module_instance) modules.append(module_instance) module_instance = CMU_behavior.CMU('CMU') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('CMU', module_instance) modules.append(module_instance) module_instance = COEX_behavior.COEX('COEX') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('COEX', module_instance) modules.append(module_instance) module_instance = CS5463_behavior.CS5463('CS5463') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('CS5463', module_instance) modules.append(module_instance) module_instance = CSEN_behavior.CSEN('CSEN') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('CSEN', module_instance) modules.append(module_instance) module_instance = DCDC_behavior.DCDC('DCDC') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('DCDC', module_instance) modules.append(module_instance) module_instance = EMU_behavior.EMU('EMU') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('EMU', module_instance) modules.append(module_instance) module_instance = EXTFLASH_behavior.EXTFLASH('EXTFLASH') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('EXTFLASH', module_instance) modules.append(module_instance) module_instance = EZRADIOPRO_behavior.EZRADIOPRO('EZRADIOPRO') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('EZRADIOPRO', module_instance) modules.append(module_instance) module_instance = FEM_behavior.FEM('FEM') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('FEM', module_instance) modules.append(module_instance) module_instance = GPIO_behavior.GPIO('GPIO') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('GPIO', module_instance) modules.append(module_instance) module_instance = I2C_behavior.I2C('I2C0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('I2C0', module_instance) modules.append(module_instance) module_instance = I2C_behavior.I2C('I2C1') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('I2C1', module_instance) modules.append(module_instance) module_instance = I2CSENSOR_behavior.I2CSENSOR('I2CSENSOR') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('I2CSENSOR', module_instance) modules.append(module_instance) module_instance = IDAC_behavior.IDAC('IDAC0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('IDAC0', module_instance) modules.append(module_instance) module_instance = IOEXP_behavior.IOEXP('IOEXP') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('IOEXP', module_instance) modules.append(module_instance) module_instance = LED_behavior.LED('LED') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('LED', module_instance) modules.append(module_instance) module_instance = LEUART_behavior.LEUART('LEUART0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('LEUART0', module_instance) modules.append(module_instance) module_instance = MODEM_behavior.MODEM('MODEM') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('MODEM', module_instance) modules.append(module_instance) module_instance = PA_behavior.PA('PA') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('PA', module_instance) modules.append(module_instance) module_instance = PRS_behavior.PRS('PRS') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('PRS', module_instance) modules.append(module_instance) module_instance = PTI_behavior.PTI('PTI') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('PTI', module_instance) modules.append(module_instance) module_instance = PYD1698_behavior.PYD1698('PYD1698') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('PYD1698', module_instance) modules.append(module_instance) module_instance = SERIAL_behavior.SERIAL('SERIAL') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('SERIAL', module_instance) modules.append(module_instance) module_instance = SPIDISPLAY_behavior.SPIDISPLAY('SPIDISPLAY') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('SPIDISPLAY', module_instance) modules.append(module_instance) module_instance = SPINCP_behavior.SPINCP('SPINCP') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('SPINCP', module_instance) modules.append(module_instance) module_instance = TIMER_behavior.TIMER('TIMER0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('TIMER0', module_instance) modules.append(module_instance) module_instance = TIMER_behavior.TIMER('TIMER1') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('TIMER1', module_instance) modules.append(module_instance) module_instance = UARTNCP_behavior.UARTNCP('UARTNCP') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('UARTNCP', module_instance) modules.append(module_instance) module_instance = USART_behavior.USART('USART0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('USART0', module_instance) modules.append(module_instance) module_instance = USART_behavior.USART('USART1') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('USART1', module_instance) modules.append(module_instance) module_instance = USART_behavior.USART('USART2') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('USART2', module_instance) modules.append(module_instance) module_instance = VCOM_behavior.VCOM('VCOM') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('VCOM', module_instance) modules.append(module_instance) module_instance = VDAC_behavior.VDAC('VDAC0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('VDAC0', module_instance) modules.append(module_instance) module_instance = VUART_behavior.VUART('VUART') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('VUART', module_instance) modules.append(module_instance) module_instance = WDOG_behavior.WDOG('WDOG') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('WDOG', module_instance) modules.append(module_instance) module_instance = WTIMER_behavior.WTIMER('WTIMER0') module_instance.load_halconfig_model(available_modules, familyobj) state.set_module_object('WTIMER0', module_instance) modules.append(module_instance) if PROFILE: stop = time.time() print(" construction of all modules completed in {:.3f} ms".format( (stop - start) * 1000)) start = time.time() # Do the hook installing after all modules have initialized PIN_Snippets.activate_runtime() PORTIO_Snippets.activate_runtime() for module_instance in modules: module_instance.activate_runtime(state) force_enable_module = RuntimeModel.get_property_value( module_instance.get_property('forceenable'), RuntimeModel.get_studio_module_by_name(module_instance.name, state.mode), False) if force_enable_module == '1': RuntimeModel.set_module_checked( RuntimeModel.get_studio_module_by_name(module_instance.name, state.mode), True, state, readonly=True) PORTIO_Snippets.onLoad(state) if PROFILE: stop = time.time() print(" activate_runtime() for all modules completed in {:.3f} ms". format((stop - start) * 1000))
def generate(context): """ Generates the relevant defines for hwconf setup to hal-config/hal-config.h """ root = initSession(context) # Get output directory from config or fall back to 'hal-config' directory output_dir = getVariable('output_dir') if not output_dir: output_dir = 'hal-config' # Get output filename from config or fall back to 'hal-config.h' output_file = getVariable('output_file') if not output_file: output_file = 'hal-config.h' hal_conf_dir = newDirectory(root, output_dir) hal_conf_h = newFile(hal_conf_dir, output_file) define_guard = output_file.upper().replace('-', '_').replace('.', '_') # Generate header and start of cloaking text = "" text += "#ifndef {}\n".format(define_guard) text += "#define {}\n".format(define_guard) text += "\n" text += "#include \"em_device.h\"\n" text += "#include \"hal-config-types.h\"\n" text += "\n" text += "// This file is auto-generated by Hardware Configurator in Simplicity Studio.\n" text += "// Any content between $[ and ]$ will be replaced whenever the file is regenerated.\n" text += "// Content outside these regions will be preserved.\n" # Push location for eval'd text pushContext(location=hal_conf_h) newContribution(hal_conf_h, text) # Initializing lists define_list = [] region_list = [] module_list = [] # Generate regions in file for transition in modeTransitions(): # Get region names from transition.modules for module in transition.modules: module_type = module.obj.object.getComponentId().split(".")[2] if not (module_type == "port" or module_type == "pin"): region_list.append(module.name) # Generate regions alphabetically in file region_list.sort() for region in region_list: if not getLocation(region): startRegion(region) endRegion() # Adding portio defines to define_list portio = transition.getModule("PORTIO").obj.object routes = add_portio_defines(portio, define_list) available_modules = Metadata.get_available_modules_for_family() familyobj = dep.Family('efr32fg13p') # Generate a module list from '_behaviour' files mod_inst = ACMP_behavior.ACMP('ACMP0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = ACMP_behavior.ACMP('ACMP1') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = ADC_behavior.ADC('ADC0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = ANTDIV_behavior.ANTDIV('ANTDIV') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = BATTERYMON_behavior.BATTERYMON('BATTERYMON') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = BTL_BUTTON_behavior.BTL_BUTTON('BTL_BUTTON') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = BULBPWM_behavior.BULBPWM('BULBPWM') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = BULBPWM_COLOR_behavior.BULBPWM_COLOR('BULBPWM_COLOR') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = BUTTON_behavior.BUTTON('BUTTON') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = CMU_behavior.CMU('CMU') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = COEX_behavior.COEX('COEX') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = CS5463_behavior.CS5463('CS5463') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = CSEN_behavior.CSEN('CSEN') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = DCDC_behavior.DCDC('DCDC') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = EMU_behavior.EMU('EMU') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = EXTFLASH_behavior.EXTFLASH('EXTFLASH') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = EZRADIOPRO_behavior.EZRADIOPRO('EZRADIOPRO') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = FEM_behavior.FEM('FEM') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = GPIO_behavior.GPIO('GPIO') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = I2C_behavior.I2C('I2C0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = I2C_behavior.I2C('I2C1') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = I2CSENSOR_behavior.I2CSENSOR('I2CSENSOR') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = IDAC_behavior.IDAC('IDAC0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = IOEXP_behavior.IOEXP('IOEXP') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = LED_behavior.LED('LED') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = LEUART_behavior.LEUART('LEUART0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = MODEM_behavior.MODEM('MODEM') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = PA_behavior.PA('PA') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = PRS_behavior.PRS('PRS') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = PTI_behavior.PTI('PTI') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = PYD1698_behavior.PYD1698('PYD1698') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = SERIAL_behavior.SERIAL('SERIAL') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = SPIDISPLAY_behavior.SPIDISPLAY('SPIDISPLAY') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = SPINCP_behavior.SPINCP('SPINCP') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = TIMER_behavior.TIMER('TIMER0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = TIMER_behavior.TIMER('TIMER1') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = UARTNCP_behavior.UARTNCP('UARTNCP') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = USART_behavior.USART('USART0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = USART_behavior.USART('USART1') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = USART_behavior.USART('USART2') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = VCOM_behavior.VCOM('VCOM') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = VDAC_behavior.VDAC('VDAC0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = VUART_behavior.VUART('VUART') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = WDOG_behavior.WDOG('WDOG') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) mod_inst = WTIMER_behavior.WTIMER('WTIMER0') mod_inst.load_halconfig_model(available_modules, familyobj) module_list.append(mod_inst) # Adding peripheral defines to list add_peripheral_defines(module_list, transition, define_list, routes) # Printing the list to hal-config.h print_defines_from_list(define_list) # Add module include text = "" text += "#if defined(_SILICON_LABS_MODULE)\n" text += "#include \"sl_module.h\"\n" text += "#endif\n" text += "\n" newContribution(hal_conf_h, text) # Ending the #ifndef newContribution(hal_conf_h, "#endif /* {} */".format(define_guard)) popContext() # Sync project modules try: framework = detect_framework(context) refresh_studio_modules(framework, module_list) except: print("project module sync failed")