Configuration / Initializing the Board

When using a Cow Pi board, a single function call is sufficient to configure all pins and fully initialize the board if no Expansion Options are used. (If expansions are used, their pins must must be configured separately, as must their initialization.)

The cowpi_setup() function does three things:

  • It initializes the standard input/output/error FILE streams at the specified bitrate

  • It configures the display module using the same cowpi_display_module_t and cowpi_display_module_protocol_t arguments as the CowPi_stdio library’s cowpi_add_display_module() function - The function returns a pointer to the display module’s FILE stream

  • It assigns the peripheral inputs and outputs to the microcontroller pins appropriate to your particular Cow Pi board, and it configures the pins accordingly

FILE *cowpi_setup(unsigned long console_bitrate, cowpi_display_module_t display_module, cowpi_display_module_protocol_t communication_protocol)

Configures the microcontroller’s pins for the expected hardware setup, configures stdout and stdin to use the USB-based serial interface between the microcontroller and the host computer, and configures the library to work with the specified display module and communication protocol.

If the Morse Code “font” is available, then stderr will use Morse Code on the right LED. Otherwise, stderr will be aliased to stdout.

If the USB-based serial interface should not be configured, then set the console_bitrate to 0. If there is not yet a display module, then set the display_module to {.display_module = NO_MODULE}. If there is not yet a display module (and the communication protocol’s pins are not otherwise used) then you may assign communication_protocol to {.protocol = NO_PROTOCOL}.

See also

cowpi_stdio_setup() in CowPi_stdio

See also

cowpi_add_display_module() in CowPi_stdio

Parameters:
  • console_bitrate – the serial interface’s bitrate, or 0 if the serial interface should not be configured

  • display_module – the display module’s details

  • communication_protocol – the communication protocol’s details

Returns:

a pointer to a FILE stream for the display module, or NULL if a stream could not be created