The large majority of technological devices can be seen as the sum of components of heterogeneous nature (electrical, mechanical, thermal, software, etc.) so that their analysis and design calls for the use of tools from different engineering disciplines. Integration among the different tools is particularly relevant at control system design level, since it is at this stage that it is required to analyze the behavior of both each single component and the system as a whole, with different levels of detail. In this paper mechatronic systems are considered, that exhibit a strong interplay between mechanical and electrical components, and the issue of modeling and designing embedded control algorithms and architectures for such systems is addressed. In particular, an integrated virtual prototyping approach for analyzing the system behavior down to embedded software level is proposed, that can be used in a wide number of situations that can represent the actual real-world operational conditions of consumer products. This approach can be used for system design (in particular at control systems level), embedded software design, and virtual testing so as to optimize and reduce the costs of late stage software development, physical prototypes, and their testing. The case study is based on some recently derived software tools that perform the co-simulation of the firmware execution and the multi-physical controlled system dynamics. The actual control software implemented in the final product can be entirely developed and tested inside the virtual prototype. To prove the validity and potentialities of the proposed approach, a real case study is presented, regarding a very common, though complex to simulate, mechatronic system such as an electric sliding gate. It turns out that the proposed environment goes beyond hardware-in-the-loop tools, since it does not require the use of specific hardware (the hardware itself is simulated in detail) but allows to analyze in detail the status of the microprocessors and peripherals at arbitrary time-scales and allows the designer to study at the earliest design stages the dynamics between the multi-physical controlled system and the firmware, without committing to a given hardware structure.