---
name: "hal_pin_new"
section: "3hal"
platform: "linux"
package: "linuxcnc-uspace-dev"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hal_pin_new"
---

# hal\_pin\_new(3hal)

creates a HAL pin

## NAME

hal\_pin\_new - creates 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\_port\_new(const char \**name*, hal\_pin\_dir\_t *dir*, hal\_port\_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\_port\_newf(hal\_pin\_dir\_t *dir*, hal\_port\_t \*\* *data\_ptr\_addr*, int *comp\_id*, const char \**fmt*, *...*)

 int hal\_pin\_new(const char \**name*, hal\_type\_t *type*, hal\_pin\_dir\_t *dir*, void \*\**data\_ptr\_addr*, int *comp\_id*)

## ARGUMENTS

- *name*

  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*

  HAL component identifier returned by an earlier call to **hal\_init**.

- *fmt,*

  printf-style format string and arguments

- *type*

  The type of the param, as specified in **[hal\_type\_t(3hal)](/hal_type_t/3hal.md)**.

## 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 0 on success, or a negative errno value on failure.

## SEE ALSO

**[hal\_type\_t(3hal)](/hal_type_t/3hal.md)**, **[hal\_link(3hal)](/hal_link/3hal.md)**
