RP6 ROBOT SYSTEM - 4. RP6 CONTROL M256 WIFI Library
4. RP6 CONTROL M256 WIFI Library
As for the robot itself, there is a comprehensive function library for the RP6-M256 with
many useful features that make life easier for beginners. The name of the library is
RP6 CONTROL M256 WIFI Library or a bit shorter: RP6M256Lib. The stopwatch, delay,
UART and I²C-bus functions are identical to those of the normal RP6Library. The I²C
bus even uses the same source code files. These are stored in the sub-folder RP6com-
mon of the RP6Library. The UART library is different as the internal structure of the
ATMEGA2560 is a bit different and the UART routines had to be optimized for the
WLAN module. We will not describe these functions again as they are mostly identical.
Refer to the relevant chapter in the RP6 manual an the example programs!
Here we only describe the functions that are exclusive to the RP6-M256 or that work a
bit differently in the RP6Lib.
Tip:
Despite all the ready to use functions, the RP6M256Lib is only a start-
ing point and far from being perfect. You can improve it and add many
additional things. Here you have to use your own programming skills!
New versions of the library will be published online. This applies also to
the example programs.
4.1.1. Initialization of the Microcontroller
void initRP6M256(void)
As you already know from the RP6Lib, this function must ALWAYS be called first in the
main function! It just has a bit different name here.
The function initializes the hardware modules of the microcontroller on the RP6-M256.
Only if you call this function right at the beginning, the microcontroller will work prop-
erly! A part will be initialized by the bootloader but not everything.
Example:
1
2
3
4
5
6
7
8
9
10
11
#include "RP6M256Lib.h"
int
main
(
void
)
{
initRP6M256
();
// Initialization
// ALWAYS CALL THIS FIRST!
// [...] Program code...
while
(
true
);
// Infinite loop
return
0
;
}
Every program for the RP6 CONTROL M256 must at least look like this! The
infinite loop in line 9 is necessary to ensure a defined end of the program!
Without this loop, the program could behave differently than expected.
Exactly as for
the controller on the main board!
Usually something useful is done in this loop. Ideas for the general structure of pro-
grams can be found in the example programs!
- 28 -