Main Content

coder.hardware

Create hardware board configuration object for C/C++ code generation from MATLAB code

Description

The coder.hardware function creates a coder.Hardware object that contains hardware board parameters for C/C++ code generation from MATLAB® code.

To use a coder.Hardware object for code generation, assign it to the Hardware property of a coder.CodeConfig or coder.EmbeddedCodeConfig object that you pass to codegen. Assigning a coder.Hardware object to the Hardware property customizes the associated coder.HardwareImplementation object and other configuration parameters for the particular hardware board.

Creation

Description

example

coder.hardware(boardname) creates a coder.Hardware object for the specified hardware board. The board must be supported by an installed support package. To see a list of available boards, call coder.hardware without input parameters.

example

coder.hardware() returns a cell array of names of boards supported by installed support packages.

Input Arguments

expand all

Hardware board name, specified as a character vector or a string scalar.

Example: 'Raspberry Pi'

Example: "Raspberry Pi"

Properties

expand all

Name of hardware board, specified as a character vector or a string scalar. The coder.hardware function sets this property using the boardname argument.

Clock rate of hardware board, specified as a double scalar.

Examples

collapse all

Configure code generation for a Raspberry Pi board and generate code for a function foo.

hwlist = coder.hardware();
if ismember('Raspberry Pi',hwlist)
    hw = coder.hardware('Raspberry Pi');
    cfg = coder.config('lib');
    cfg.Hardware = hw;
    codegen foo -config cfg -report
end

Before creating a coder.Hardware object for a hardware board, check that the board is supported by an installed support package.

List all boards for which a support package is installed.

hwlist = coder.hardware()

Test for an installed support package for a particular board.

hwlist = coder.hardware();
if ismember('Raspberry Pi',hwlist)
    hw = coder.hardware('Raspberry Pi');
end

Tips

Introduced in R2015b