GPIO
This section refers to the following sample application(s):
02-gpio
02-gpio_net
A General Purpose Input/Output (GPIO) is a pin that can be configured in software to serve either as an input or as an output pin. On the LTC5800
When using a DC9003, make sure that the V+
pin is never in contact with any other pin on the mote. The DC9006 supplies 12V through this pin, and connecting any mote IO to it will destroy the mote.
GPIO on
LTC5800
The following list shows the device names, the pins they are mapped to, and the location of the pins on the
board. Some of the pins are reserved for internal use by theSmartMesh network stack
, and must not be used by your application.When using a GPIO as an input as arming notifications, we recommend you introduce a delay (e.g. 100ms) when re-arming the notification to the opposite level for de-bouncing.
Device Name | Special Function | board | LTC5800 chip | LTP5901/2 board | |||
Header | Silkscreen text | pin name | pin number | pin name | pin number | ||
---|---|---|---|---|---|---|---|
DN_GPIO_PIN_0_DEV_ID | SPI Master Slave Select 2 (active low) | P2 |
| DP0/GPIO0 | 36 | DP0 | 28 |
DN_GPIO_PIN_3_DEV_ID | IPCS Slave Select | P1 | I SSn | IPCS_SSn | 45 | IPCS_SSn/GPIO3 | 39 |
DN_GPIO_PIN_4_DEV_ID | IPCS Clock | P1 | I SCK | IPCS_SCK | 44 | IPCS_SCK/GPIO4 | 36 |
DN_GPIO_PIN_5_DEV_ID | IPCS Master-Out-Slave-In | P1 | I MOSI | IPCS_MOSI | 42 | IPCS_MOSI/GPIO5 | 35 |
DN_GPIO_PIN_6_DEV_ID | IPCS Master-In-Slave-Out | P1 | I MISO | IPCS_MISO | 40 | IPCS_MISO/GPIO6 | 33 |
DN_GPIO_PIN_9_DEV_ID | SPI Master Master Clock | P3 | M SCK | SPIM_SCK | 43 | SPIM_SCK | 41 |
DN_GPIO_PIN_10_DEV_ID | SPI Master Master-Out-Slave-In | P3 | M MOSI | SPIM_MOSI | 41 | SPIM_MOSI | 40 |
DN_GPIO_PIN_11_DEV_ID | SPI Master Master-In-Slave-Out | P3 | M MISO | SPIM_MISO | 39 | SPIM_MISO | 38 |
DN_GPIO_PIN_12_DEV_ID | SPI Master Slave Select 0 (active low) | P3 | M SS0n | SPIM_SS_0n | 47 | SPIM_SS_0n | 44 |
DN_GPIO_PIN_13_DEV_ID | SPI Master Slave Select 1 (active low) | P2 | M SS1n | SPIM_SS_1n | 46 | SPIM_SS_1n | 43 |
DN_GPIO_PIN_16_DEV_ID | P2 | PWM0 | PWM0 | 49 | PWM0 | 46 | |
DN_GPIO_PIN_20_DEV_ID | P2 | DP1/IO20 (D5/D8 LEDs) | DP1 | 48 | DP1 | 45 | |
DN_GPIO_PIN_21_DEV_ID | P2 | DP2 | DP2 | 34 | DP2/GPIO21 | 26 | |
DN_GPIO_PIN_22_DEV_ID | P2 | DP3/IO22 (D7/D10 LEDs) | DP3 | 33 | DP3 | 25 | |
DN_GPIO_PIN_23_DEV_ID | P2 | DP4 (D6/D9 LEDs) | DP4 | 27 | DP4 | 21 | |
DN_GPIO_PIN_26_DEV_ID | SPI Slave Master-Out-Slave-In | P2 | S MOSI | SPIS_MOSI | 51 | GPIO26/SPIS_MOSI | 48 |
The 02-gpio
Sample Application
The 02-gpio
sample application creates two tasks:
- The gpioToggleTask() task configures a pin as output and toggles its state every second. On the board, this corresponds to the blue LED.
- The gpioNotifTask() task waits for notifications from a different pin configured as input. On the board, this corresponds to the pin labeled
DP2
on the silkscreen. Connecting this pin to the supply voltage triggers a notification; disconnecting it triggers another one, as shown in the CLI output captured below:
gpio app, ver 1.0.0.1 SmartMeshIP stack, ver 1.2.1.3 gpioNotifTask: level=1. gpioNotifTask: level=0.
The 02-gpio
sample application does not implement software de-bouncing. You might see a stream of notifications printed if you don't have a circuit which implements hardware de-bouncing.
The 02-gpio_net
Sample Application
The 02-gpio_net
sample application periodically reads the state of a pin, and sends a corresponding packet to the manager. You can configure the period between samples, and the 1-byte value to send when the pin is high or low.
The figure below is a typical CLI output:
gpio_net app, ver 1.0.0.1 SmartMeshIP stack, ver 1.2.1.3 Current config: - lowval: 255 - highval: 1 - period: 10000 6661 : Joining 8808 : Connected 15096 : Active samplePinLevel=0, sent 0xff samplePinLevel=0, sent 0xff samplePinLevel=0, sent 0xff samplePinLevel=1, sent 0x01 samplePinLevel=1, sent 0x01 samplePinLevel=1, sent 0x01
In this case:
- period is 10000ms, i.e. the application sends one packet to the manager every 10s.
- highval is 255, i.e. the application sends the 1-byte payload
0xff
to the manager when the pin is high. - lowval is 1, i.e. the application sends the 1-byte payload
0x01
to the manager when the pin is low.
In the figure above, the pin was tied to ground for the first 30s, then tied high for the next 30s.
You can connect ApiExplorer
to your
SmartMesh manager
to see the data received:At any time, you can change the configuration values through CLI:
- type "
period 5000
" to publish every 5s. - type "
highval 10
" to send byte0x0a
when the pin is tied high. - type "
lowval 11
" to send byte0x0b
when the pin is tied low.
How the 02-gpio_net
sample application registers to extra CLI commands is covered in the CLI Module section.
Refer to the
SmartMesh On-Chip API html documentation
in the /doc
directory of the for documentation about this feature.