Contents
- 2 Propeller Library
- 4 Stdio Devices Library
- 5 Standard C Library
Simple Libraries
Parallax Education spent a great amount of time/effort making the Simple Libraries found in the SimpleIDE package. The main reason for Simple Libraries is for supporting the Propeller-C Learning System. Simple Libraries are designed to fit in the memory footprint of the Propeller chip, and have very good documentation.
For more on Simple Libraries, visit Learn Propeller C
Traditional standard C libraries are also available, and are presented below.
Propeller Library
The Propeller Library gives programmers access to Propeller hardware functions.
Propeller Library API 'propeller.h'
COG Library API 'cog.h'
COG Device Library
COG devices are Propeller COG programs that emulate protocols or hardware.I2C
The I2C library is part of the Propeller-GCC library and is used for ECOG programming.
FDSThe FDS library (Full Duplex Serial) can be used for serial IO in addition to the SimpleSerial console.
Other COG devices are being written during the Propeller-GCC Beta phase.
Stdio Devices Library
The stdio library in Propeller GCC is just one way to use IO devices. It is possible to use custom devices with Propeller that have a smaller memory footprint for simple IO. If lots of console or other IO is expected, the stdio devices may be a smaller alternative.
Propeller-GCC stdio methodology is detailed here:
Library APIs for setting up custom devices:
Some built-in console devices
Standard IO devices can be replaced with any driver that is written according to the driver API.
SSER is the default console IO device driver for stdin, stdout, and stderr.
Changing the default baud rate (115200bps) of the serial drivers requires using freopen.
* Main program function.
void main(void)
freopen('SSER:9600,31,30', 'w', stdout);
freopen('SSER:9600,31,30', 'r', stdin);
printf('Hello, Worldn');
SSER
This names the Simple Serial default stdio console device and is used if there is no driver list.
FDS
This names the Full Duplex Serial stdio console device and can replace the SSER driver by defining a driver list like as:
* @file file.c
*/
#include <propeller.h>
extern _Driver _FullDuplexSerialDriver;
/* This is a list of all drivers we can use in the
* program. The default _InitIO function opens stdin,
* stdout, and stderr based on the first driver in
* the list (the full duplex serial driver in this case).
_Driver *_driverlist[] = {
NULL
NUL
The null driver can be used as a place-holder for the standard IO (stdin, stdout, stderr) driver instead of SSER and FDS. This allows us to install a stdio file driver for example without using the serial console.
* @file file.c
*/
#include <propeller.h>
extern _Driver _NullDriver;
/* This is a list of all drivers we can use in the
* program. The default _InitIO function opens stdin,
* stdout, and stderr based on the first driver in
*/
&_NullDriver,
&_FileDriver, // file driver must always be last on the list before NULL
};
Console and File system driver initialization
Propeller GCC and propeller-load can automatically configure the console and file system based on parameters in the board configuration file. The SD card pins are defined in the board configuration file. The propeller-load start-up sequence does the mounting for you. Below is a minimal example for opening a file. An example board configuration file follows.
* @file file.c
*/
#include <propeller.h>
extern _Driver _SimpleSerialDriver;
/* This is a list of all drivers we can use in the
* program. The default _InitIO function opens stdin,
* stdout, and stderr based on the first driver in
*/
&_SimpleSerialDriver,
NULL
* Main program function.
void main(void)
char name[20];
waitcnt(CLKFREQ+CNT); // pause for terminal to open
sprintf(name,'Test'); // test file name
printf('Can't open file %s.n',name);
else {
fclose(fp1);
while(1);
# IDE:SDXMMC
clkmode: XTAL1+PLL16X
rxpin: 31
cache-driver: eeprom_cache.dat
cache-param1: 0
eeprom-first: TRUE
sdspi-do: 0
sdspi-di: 2
Propeller GCC supports these libraries defined by ANSI C and the international standard ISO/IEC 9899 ('the standard'). Propeller-GCC library code is neither based on GNU libraries nor the Newlib library package because those libraries are simply too big for Propeller HUB memory. Library code is derived from BSD and public domain sources.
Links to library man pages are provided here for programming convenience. The cplusplus.com site is a very good reference. All the links below point to pages found here: http://www.cplusplus.com/reference/.
Not all errno defines above are supported in Propeller-GCC. The standard only requires a few errno types, i.e. EDOM, EILSEQ, ERANGE, and errno. Propeller-GCC supports these errno macros.
Please see Stdio Devices Library above for information on setting up standard IO devices.
Wide-character classification and mapping utilities <wctype.h>