Machinekit

Machinekit

hal_pin_new

NAME

hal_pin_new — Create a HAL pin

SYNTAX

int hal_pin_bit_new ( const char *name, hal_pin_dir_t dir, hal_bit_t data_ptr_addr, int comp_id )

int hal_pin_float_new ( const char *name, hal_pin_dir_t dir, hal_float_t data_ptr_addr, int comp_id )

int hal_pin_u32_new ( const char *name, hal_pin_dir_t dir, hal_u32_t data_ptr_addr, int comp_id )

int hal_pin_s32_new ( const char *name, hal_pin_dir_t dir, hal_s32_t data_ptr_addr, int comp_id )

int hal_pin_bit_newf ( hal_pin_dir_t dir, hal_bit_t data_ptr_addr, int comp_id, const char *fmt, …​ )

int hal_pin_float_newf ( hal_pin_dir_t dir, hal_float_t data_ptr_addr, int comp_id, const char *fmt, …​ )

int hal_pin_u32_newf ( hal_pin_dir_t dir, hal_u32_t data_ptr_addr, int comp_id, const char *fmt, …​ )

int hal_pin_s32_newf ( hal_pin_dir_t dir, hal_s32_t data_ptr_addr, int comp_id, const char *fmt, …​ )

int hal_pin_new ( const char *name, hal_type_t type, hal_in_dir_t dir, void data_ptr_addr, int comp_id )

ARGUMENTS

name
The name of the pin

dir
The direction of the pin, from the viewpoint of the component.

It may be one of HAL_IN, HAL_OUT, or HAL_IO.
Any number of HAL_IN or HAL_IO pins may be connected to the same signal, but at most one HAL_OUT pin is permitted.
A component may assign a value to a pin that is HAL_OUT or HAL_IO, but may not assign a value to a pin that is HAL_IN.

data_ptr_addr
The address of the pointer-to-data, which must lie within memory allocated by hal_malloc.

comp_id
A HAL component identifier returned by an earlier call to hal_init.

fmt, …​
A printf-style format string and arguments

type
The type of the param, as specified in hal_type_t.

DESCRIPTION

The hal_pin_new family of functions create a new pin object.
Once a pin has been created, it can be linked to a signal object using hal_link.
A pin contains a pointer, and the component that owns the pin can dereference the pointer to access whatever signal is linked to the pin. (If no signal is linked, it points to a dummy signal.)

There are functions for each of the data types that the HAL supports.
Pins may only be linked to signals of the same type.

RETURN VALUE

Returns a HAL status code.

SEE ALSO

hal_type_t
hal_link