Serial is created by default as part of the Arduino infrastructure, in the same way as it has the ISR's that work the millis() function for time keeping etc.
The reason there is Software serial, is for use on devices like the ATMega328 e.g in the Uno, which only have one hardware serial device, - which is connected to the PC
So if you need the Uno to communicate to another Serial device e.g. a Serial Bluetooth module , you need to use Software serial which gives you serial on pins other than D0 and D1 (which are hard wired to the PC on the Uno etc).
snoop911:
but where is the original 'Serial' object at? I'm sure it's buried deep within some core library cpp
The Serial object is declared in HardwareSerial.h and defined in HardwareSerial.cpp. On platforms that have multiple hardware serial ports, these files also define Serial1, Serial2 and so on. It also defines Serial_ for the odd platforms where there is a USB virtual serial port. HardwareSerial.h is automagically #included in your sketch via the #include Arduino.h which the IDE inserts for you before compilation.
snoop911:
I'm trying to migrate over to AtmelStudio and I included HardwareSerial0.cpp/HardwareSerial.h
Rather than #including individual files such as HardwareSerial.h I suggest you just #include Arduino.h, which will include the other files needed. (Note that you'd have to include that in each compilation unit i.e. each .c/.cpp source file that referred to Arduino declarations.
yet, if try to use the same UBRR0H symbol in my local code it doesn't see it!
I suppose it's academic at this point, but it's interesting that HardwareSerial.h doesn't 'include' any file that has the UBRRH/UBRR0H, so why wouldn't my local code see it?
snoop911:
I suppose it's academic at this point, but it's interesting that HardwareSerial.h doesn't 'include' any file that has the UBRRH/UBRR0H, so why wouldn't my local code see it?
The defines get included from an include in Arduino.h
The serial stuff is included after it. As includes are copy/paste jobs, Arduino.h becomes a long file with the UBRRH stuff first then the Serial, so its visible there.
For example, Func() will be defined as the include order allows SOME_DEFINE to be visible before its used ( if you include myheader.h ):