Bios Example
KoliadaES maintains a simple BIOS (basic i/o system)
The bios is extensible independently of all other systems. The bios defines the following i/o channels;
_STDIN 0 - std input for getch(), etc _STDOUT 1 - std output for print() and printf() _STDERR 2 - std output for error() _STDDBG 3 - std output for debug() _STDPRN 4 - std output for _STDLOG 5 - std log output _STDKEY 6 - std input for sys.GetchWait()
These default to system standard i/o which is typically a UART. The system uart is determined as part of the BoardConfig hardware configuration file (BCF). The BCF is a separate flash page that describes the system hardware independently of the system or application code.
Since the bios is extensible, it is possible to replace any or all of the i/o handlers to provide alternate services - syslog, log to flash, etc.
Extending the bios is beyond the scope of this example.
Hardware/Boards Required
Before you proceed with this tutorial, you must have the latest KoliadaESDK(TM) and KoliadaES environment setup. For more information on the setup check out Koliada Getting started. This example will run on any processor board that has UART serial communication and whereas this tutorial uses the PIEP CC2541, you can use any compatible processor board.
Step 1
Before working on this example, make sure you have set the latest KoliadaESDK(TM). For information on KoliadaESDK(TM) setup see here.
Note: After making sure the KoliadaESDK(TM) is setup correctly, the BuildConfig needs to be built & flashed only if you have changed any board configuration. You can find an example BoardConfig project here: KoliadaESDK(TM)/examples/BoardConfig.
In this particular example there are no I/O configuration changes, and we can move on to build and flash the TestBios application.
Step 2
You find the source for TestBios here KoliadaESDK(TM)/examples/TestBios.
Now build the project and hit 'Download to Target'.
You should see the following output on your serial terminal
Fig. 2: Output of TestBios Example
The output shows the TestBios program being loaded which then causes a reset followed by KoliadaES initialization.
As KoliadaES boots, it shows the installed board configuration details, including GPIO configuration, for the TI CC2541 Board we are using.
The Testbios application is then run and the print, debug, error and trace outputs are shown.
Once you hit any terminal key the program exits out of the application and back to KoliadaES.
*For more information on configuring KoliadaES GPIOs, see GPIO pin setup and Board configuration example
*For more information on KoliadaES initialization, see Anatomy of KoliadaES Bootstrap Output
Explanation
void TestBios() { debug(">>%s\n", __FUNC__); // print something to the world print("print - hello world\n", 23); // synonymous with printf debug("debug - hello world\n", 23); error("error - hello world\n", 23); trace("trace - hello world\n", 23); // outputs to both PRN and LOG (may be split) printf("hit any key in the terminal i/o window to continue: "); // sys.Getc defaults to a poll wait for a key - if there is no key it returns -1 // sys.GetchWait waits for a time (ms) before returning, again returning -1 if no key // sys.Getc and sys.GetchWait may be redirected independently of each other // wait for a key press // return a value to the monitor int key; while ((key = getch()) == -1); // wait for a keypress printf("\nyou hit key %u '%c' (0x%x)\n", key, key, key); // remember, this is desgned to be an extensible bios, not the next best thing for serial communications. debug("<<%s\n", __FUNC__); }
We can walkthrough TestBios.c now.
debug(">>%s\n", __FUNC__)
This simply indicates starting the 'TestBios' program.
print("print - hello world\n", 23); // synonymous with printf debug("debug - hello world\n", 23); error("error - hello world\n", 23); trace("trace - hello world\n", 23); // outputs to both PRN and LOG (may be split)
The functions print, debug, error and trace are different standard output functions. Since, by default, all these calls use the same output handler you will see all the results on the local terminal. However, by installing your own bios handlers, STDIO can be re-directed for alternate sources & sinks. For an example of installing a bios stdio handler, see the Wiznet example where STDIN, STDOUT & STDERR are redirected to a remote terminal whilst the rest report to the local terminal. STDIO is redirected by function handlers and they can do pretty much anything they might need in order to source/sink redirected chars.
int key; while ((key = getch()) == -1); // wait for a keypress printf("\nyou hit key %u '%c' (0x%x)\n", key, key, key);
getch() waits for the key press and allows the program to continue, with printf indicating the key used.
debug("<<%s\n", __FUNC__)
This indicates that 'TestBios' is about to exit.
The entry/exit debug staments are not required, they are just there for execution clarity.
Now you have successfully run the first KoliadaES example. You can now explore KoliadaES using our other examples & boards.