STC15W408AS library 0.9.0
Macros
Pin

Macros

#define pin_quasi_bidiretional_init(port, port_pin)
 Init pin in in QUASI_BIDIRECTIONAL mode. More...
 
#define pin_push_pull_init(port, port_pin)
 Init pin in in PUSH_PULL mode. More...
 
#define pin_input_only_init(port, port_pin)
 Init pin in in INPUT_ONLY mode. More...
 
#define pin_open_drain_init(port, port_pin)
 Init pin in in OPEN_DRAIN mode. More...
 
#define is_pin_mode_quasi_bidiretional(port, port_pin)   ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) == 0 ) )
 Assert pin in quasy-bidirectional mode. More...
 
#define is_pin_mode_push_pull(port, port_pin)   ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) != 0) )
 Assert pin in push-pull mode. More...
 
#define is_pin_mode_input_only(port, port_pin)   ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) == 0) )
 Assert pin in input-only mode. More...
 
#define is_pin_mode_open_drain(port, port_pin)   ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) != 0) )
 Assert pin in open-drain mode. More...
 
#define pin_port_quasi_bidiretional_init(port)
 Set quasy-bidirectional mode for all port pins. More...
 
#define pin_port_pull_push_init(port)
 Set pull-push mode for all port pins. More...
 
#define pin_port_input_only_init(port)
 Set input-only mode for all port pins. More...
 
#define pin_port_open_drain_init(port)
 Set open-drain mode for all port pins. More...
 

Detailed Description

Pin modes data structures and routines

Author
Michael Golovanov

Macro Definition Documentation

◆ is_pin_mode_input_only

#define is_pin_mode_input_only (   port,
  port_pin 
)    ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) == 0) )

Assert pin in input-only mode.

Returns
true if pin in input-only mode, otherwise false

◆ is_pin_mode_open_drain

#define is_pin_mode_open_drain (   port,
  port_pin 
)    ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) != 0) )

Assert pin in open-drain mode.

Returns
true if pin in open-drain mode, otherwise false

◆ is_pin_mode_push_pull

#define is_pin_mode_push_pull (   port,
  port_pin 
)    ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) != 0) )

Assert pin in push-pull mode.

Returns
true if pin in push-pull mode, otherwise false

◆ is_pin_mode_quasi_bidiretional

#define is_pin_mode_quasi_bidiretional (   port,
  port_pin 
)    ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) == 0 ) )

Assert pin in quasy-bidirectional mode.

Returns
true if pin in quasy-bidirectional mode, otherwise false

◆ pin_input_only_init

#define pin_input_only_init (   port,
  port_pin 
)
Value:
{ \
bit_set(port ## M1, 1 << port_pin); \
bit_clr(port ## M0, ~(1 << port_pin)); \
}

Init pin in in INPUT_ONLY mode.

Input only output have high impedance

Set mode for pin in port. For example for pin P10 call this routine with P1, 0 arguments

Parameters
portpin port for example P1, P3 and etc
port_pinuint8_t pin mumber in port 0..7

◆ pin_open_drain_init

#define pin_open_drain_init (   port,
  port_pin 
)
Value:
{ \
bit_set(port ## M1, 1 << port_pin); \
bit_set(port ## M0, 1 << port_pin); \
}

Init pin in in OPEN_DRAIN mode.

internal pull-up resistors should be disabled and external pull-up resistors need to join.

Set mode for pin in port. For example for pin P10 call this routine with P1, 0 arguments

Parameters
portpin port for example P1, P3 and etc
port_pinuint8_t pin mumber in port 0..7

◆ pin_port_input_only_init

#define pin_port_input_only_init (   port)
Value:
{ \
port ## M1 = 0xff; \
port ## M0 = 0x00; \
}

Set input-only mode for all port pins.

Parameters
portpin port for example P1, P3 and etc

◆ pin_port_open_drain_init

#define pin_port_open_drain_init (   port)
Value:
{ \
port ## M1 = 0xff; \
port ## M0 = 0xff; \
}

Set open-drain mode for all port pins.

Parameters
portpin port for example P1, P3 and etc

◆ pin_port_pull_push_init

#define pin_port_pull_push_init (   port)
Value:
{ \
port ## M1 = 0x00; \
port ## M0 = 0xff; \
}

Set pull-push mode for all port pins.

Parameters
portpin port for example P1, P3 and etc

◆ pin_port_quasi_bidiretional_init

#define pin_port_quasi_bidiretional_init (   port)
Value:
{ \
port ## M1 = 0x00; \
port ## M0 = 0x00; \
}

Set quasy-bidirectional mode for all port pins.

Parameters
portpin port for example P1, P3 and etc

◆ pin_push_pull_init

#define pin_push_pull_init (   port,
  port_pin 
)
Value:
{ \
bit_clr(port ## M1, ~(1 << port_pin)); \
bit_set(port ## M0, 1 << port_pin); \
}

Init pin in in PUSH_PULL mode.

Push-pull output(strong pull-up output,current can be up to 20mA, resistors need to be added to restrict current

Set mode for pin in port. For example for pin P10 call this routine with P1, 0 arguments

Parameters
portpin port for example P1, P3 and etc
port_pinuint8_t pin mumber in port 0..7

◆ pin_quasi_bidiretional_init

#define pin_quasi_bidiretional_init (   port,
  port_pin 
)
Value:
{ \
bit_clr(port ## M1, ~(1 << port_pin)); \
bit_clr(port ## M0, ~(1 << port_pin)); \
}

Init pin in in QUASI_BIDIRECTIONAL mode.

QUASI_BIDIRECTIONAL mode is default pin mode and set after MCU power on

Set mode for pin in port. For example for pin P10 call this routine with P1, 0 arguments

Parameters
portpin port for example P1, P3 and etc
port_pinuint8_t pin mumber in port 0..7