ARDUINO MEGA Functions Serial Link
| Line 32: | Line 32: | ||
|<syntaxhighlight lang="robotc"> | |<syntaxhighlight lang="robotc"> | ||
getChar(uartOne); // retrieve the next char from UART Port 'uartOne' | getChar(uartOne); // retrieve the next char from UART Port 'uartOne' | ||
| + | </syntaxhighlight> | ||
| + | |- | ||
| + | |} | ||
| + | |- | ||
| + | |} | ||
| + | <br /> | ||
| + | |||
| + | == sendChar == | ||
| + | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
| + | |- | ||
| + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">sendChar</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">const </span><span class="bigKeywordB">TUARTs </span><span class="bigCodeBasic">nPort</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">nChar</span><span class="bigCodePunc">)</span> | ||
| + | |- | ||
| + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Function will send the next character to port 'nPort'. | ||
| + | |||
| + | |||
| + | {| class="parameterTable" cellpadding="5%" width="100%" | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
| + | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''nPort'' | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A sensor port or name | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_TUARTs|TUARTs]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''nChar'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|A char to send to 'nPort'. (Can be a short or a char) | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[Data_Types#dataType_short|short]] | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | |||
| + | {| | ||
| + | |- | ||
| + | |<syntaxhighlight lang="robotc"> | ||
| + | sendChar(uartOne, 'B'); // send the next char from UART Port 'uartOne' | ||
| + | </syntaxhighlight> | ||
| + | |- | ||
| + | |} | ||
| + | |- | ||
| + | |} | ||
| + | <br /> | ||
| + | |||
| + | == setBaudRate == | ||
| + | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
| + | |- | ||
| + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">setBaudRate</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">const </span><span class="bigKeywordB">TUARTs </span><span class="bigCodeBasic">nPort</span><span class="bigCodePunc">, </span><span class="bigKeywordB">TBaudRate </span><span class="bigCodeBasic">nBaudRate</span><span class="bigCodePunc">)</span> | ||
| + | |- | ||
| + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Function will set the Baud Rate for port 'nPort'. | ||
| + | Acceptable Baud Rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 200000, 230400 and 250000. | ||
| + | |||
| + | |||
| + | {| class="parameterTable" cellpadding="5%" width="100%" | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
| + | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''nPort'' | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|A sensor port or name | ||
| + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|[[Data_Types#dataType_TUARTs|TUARTs]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''nBaudRate'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The baud rate to use | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[Data_Types#dataType_TBaudRate|TBaudRate]] | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | |||
| + | {| | ||
| + | |- | ||
| + | |<syntaxhighlight lang="robotc"> | ||
| + | setBaudRate(uartOne, baudRate9600); // retrieve the next char from UART Port 'uartOne' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
Revision as of 09:31, 10 May 2012
ARDUINO → Functions and Variables → ARDUINO MEGA Functions Serial Link
The Arduino MEGA has 4 user serial ports - 1 reversed for the system and 3 user controllable serial ports. These serial ports can be configured in code or via the Motors and Sensor Setup window. The serial ports are buffered as well, with a 70 byte receive buffer and a 40 byte transmit buffer.
|
| |||||||
getChar
| short getChar(const TUARTs nPort) | |||||||
| (short) Function will retrieve the next character from the buffer that was sent to port 'nPort'.
|
sendChar
| void sendChar(const TUARTs nPort, short nChar) | ||||||||||
| (void) Function will send the next character to port 'nPort'.
|
setBaudRate
| void setBaudRate(const TUARTs nPort, TBaudRate nBaudRate) | ||||||||||
| (void) Function will set the Baud Rate for port 'nPort'.
Acceptable Baud Rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 200000, 230400 and 250000.
|
sendChar
| void sendChar(const TUARTs nPort, short nChar) | ||||||||||
| (void) Function will send the next character to port 'nPort'.
|
setBaudRate
| void setBaudRate(const TUARTs nPort, TBaudRate nBaudRate) | ||||||||||
| (void) Function will set the Baud Rate for port 'nPort'.
Acceptable Baud Rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 200000, 230400 and 250000.
|
