where does the hardware initialization happens

Hi,

I am using Teensy board for keyboard and mouse simulation. I can find only two functions
void setup() and void loop(), but I don't know form where these functions has been called. Also from where the clock initialization and other hardware initializations are happening? If any body can help me in this it will be helpful for me to understand the complete working of the teensy software.

Thanks in advance
Abul Hasan

The IDE compiles a hidden main() function into the code it produces. The main() function calls an initialisation function, the setup() function then repeatedly calls the loop() function.

Thank you so much for your swift reply.

Can we able to see that hidden main() function and edit if needed?

Why would you want to do this? Do you have stuff that really really needs to happen before setup() is called?

Abulhasan:
Can we able to see that hidden main() function and edit if needed?

I don't have teensy installed but for Arduino AVR Boards it's at hardware/arduino/avr/cores/arduino/main.cpp inside your Arduino IDE installation folder or Arduino15/packages/arduino/hardware/avr/1.6.12/cores/arduino/main.cpp if you've installed a newer version(1.6.12 in this case). Teensy's will probably be in a similar location to the first. Something like hardware/teensy/avr/cores/teensy/main.cpp inside your Arduino IDE installation folder. In Arduino AVR Boards' main.cpp there are potentially 3 functions called before setup():

	init();

	initVariant();

#if defined(USBCON)
	USBDevice.attach();
#endif

Thank you for your reply :)...

We are facing an issue that when we connect our Teensy board to a windows PC it is working with the descriptor which has been provided in the given library. But the same descriptor is not working in Linux PC. We assumed that when a USB mouse is connected to either Windows PC or Linux, it will work fine then why not Teensy? Just to analysis the issue I am trying to understand the software flow of initialization, USB handshake, communication between the Teensy and PC.

That's the reason why I am eager to know how the initialization part is working.

Disclaimer: no experience with a Teensy.

What do you mean by descriptor? Com port? In Windows e.g. COM4, in Linux e.g. /dev/ttyS0 (or whatever)? Or something like a file descriptor (windows does not know the idea of file descriptors)?

What do you mean by library; Arduino/Teensy library, PC library?

What you're saying does not quite make sense to me (but see disclaimer above). Even an Arduino without a program (compiled ino) loaded should be recognized by a Linux machine.

No, it makes sense for the Teensy. It can present multiple USB "end points" to the host. It can simultaneously be a mouse and a serial port, for example. This is configured in the Tools menu and doesn't appear in setup().

I don't know why it wouldn't work on Linux. I guess you have to ask the same question over at the Teensy forums.