-
Notifications
You must be signed in to change notification settings - Fork 7
pinToggle
gicking edited this page Jan 27, 2018
·
3 revisions
Toggle the output state of an I/O pin from low (= 0V) to high (= 3.3V or 5V, depending on supply).
If the pin has been configured as an OUTPUT
via pinMode() or portMode(),
this command toggles the pin output state.
Notes:
- after reset all I/O pins are configured as
INPUT
- if a pin is configured as
INPUT*
,pinToggle()
has no effect.
- defined in
gpio.h
- auto-loaded in
main_general.h
- no
#define
required
pinToggle(pPort, pin)
-
input:
- pPort: address of port to set, e.g.
&PORT_A
- pin: pin you wish to set (0..7)
- pPort: address of port to set, e.g.
-
output:
- none
- Nothing
The below code makes pin PD0
(=LED on STM8S Discovery) an OUTPUT
and toggles it HIGH
and LOW
with 1s delay.
#include "main_general.h" // board-independent main
void setup()
{
pinMode(&PORT_D, 0, OUTPUT); // set PD0 as output
}
void loop()
{
pinToggle(&PORT_D, 0); // toggle PD0 state
delay(1000); // wait 1s
}
To avoid damage
- do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
- for
OUTPUT
pins assert that sink and source currents are below the specificied limits - do not directly connect two
OUTPUT
pins. If e.g. half-duplex is required, use a pull-up andOUTPUT_OPENDRAIN
, instead
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific