coder.Hardware - Create hardware board configuration object for C/C++ code generation from
MATLAB code - MATLAB ([original](http://www.mathworks.com/access/helpdesk/help/coder/ref/coder.hardware.html)) ([raw](?raw))
Main Content
Create hardware board configuration object for C/C++ code generation fromMATLAB code
Description
The coder.hardware
function creates acoder.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 theHardware
property of a coder.CodeConfig or coder.EmbeddedCodeConfig object that you pass tocodegen
. Assigning a coder.Hardware
object to theHardware
property customizes the associated coder.HardwareImplementation object and other configuration parameters for the particular hardware board.
Note
The code generator enables you to extend the range of supported hardware by using thetarget.create and target.add functions to register new devices. After you register a new device, you can create acoder.Hardware
object for this new device as well.
Creation
Syntax
Description
coder.hardware([boardname](#mw%5Fde2f239d-12f2-480d-ae76-c15fe2171617))
creates acoder.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.
coder.hardware()
returns a cell array of names of boards supported by installed support packages.
Input Arguments
boardname
— hardware board name
character vector | string scalar
Hardware board name, specified as a character vector or a string scalar.
Example: 'Raspberry Pi'
Example: "Raspberry Pi"
Properties
Name
— Name of hardware board
character vector | string scalar
Name of hardware board, specified as a character vector or a string scalar. Thecoder.hardware
function sets this property using theboardname
argument.
CPUClockRate
— Clock rate of hardware board
100 (default) | double scalar
Clock rate of hardware board, specified as a double scalar.
Examples
Generate Code for a Supported Hardware Board
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
Check Supported Hardware Boards
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
- In addition to the
Name
andCPUClockRate
properties, acoder.Hardware
object has dynamic properties specific to the hardware board. - To configure code generation parameters for processor-in-the-loop (PIL) execution on a supported hardware board, use
coder.hardware
. See PIL Execution with ARM Cortex-A at the Command Line (Embedded Coder) and PIL Execution with ARM Cortex-A by Using the MATLAB Coder App (Embedded Coder). PIL execution requires Embedded Coder®.
Version History
Introduced in R2015b