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

 chip, all GPIO pins have interrupt capabilities.

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 

DC9003

 board. Some of the pins are reserved for internal use by the 

SmartMesh 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 NameSpecial Function

DC9003

board
LTC5800 chipLTP5901/2 board


HeaderSilkscreen textpin namepin numberpin namepin number
DN_GPIO_PIN_0_DEV_IDSPI Master Slave Select 2 (active low)P2

DP0/M SS2n

DP0/GPIO036DP028
DN_GPIO_PIN_3_DEV_IDIPCS Slave SelectP1I SSnIPCS_SSn45IPCS_SSn/GPIO339
DN_GPIO_PIN_4_DEV_IDIPCS ClockP1I SCKIPCS_SCK44IPCS_SCK/GPIO436
DN_GPIO_PIN_5_DEV_IDIPCS Master-Out-Slave-InP1I MOSIIPCS_MOSI42IPCS_MOSI/GPIO535
DN_GPIO_PIN_6_DEV_IDIPCS Master-In-Slave-OutP1I MISOIPCS_MISO40IPCS_MISO/GPIO633
DN_GPIO_PIN_9_DEV_IDSPI Master Master ClockP3M SCKSPIM_SCK43SPIM_SCK41
DN_GPIO_PIN_10_DEV_IDSPI Master Master-Out-Slave-InP3M MOSISPIM_MOSI41SPIM_MOSI40
DN_GPIO_PIN_11_DEV_IDSPI Master Master-In-Slave-OutP3M MISOSPIM_MISO39SPIM_MISO38
DN_GPIO_PIN_12_DEV_IDSPI Master Slave Select 0 (active low)P3M SS0nSPIM_SS_0n47SPIM_SS_0n44
DN_GPIO_PIN_13_DEV_IDSPI Master Slave Select 1 (active low)P2M SS1nSPIM_SS_1n46SPIM_SS_1n43
DN_GPIO_PIN_16_DEV_ID
P2PWM0PWM049PWM046
DN_GPIO_PIN_20_DEV_ID
P2DP1/IO20 (D5/D8 LEDs)DP148DP145
DN_GPIO_PIN_21_DEV_ID
P2DP2DP234DP2/GPIO2126
DN_GPIO_PIN_22_DEV_ID
P2DP3/IO22 (D7/D10 LEDs)DP333DP325
DN_GPIO_PIN_23_DEV_ID
P2DP4 (D6/D9 LEDs)DP427DP421
DN_GPIO_PIN_26_DEV_IDSPI Slave Master-Out-Slave-InP2S MOSISPIS_MOSI51GPIO26/SPIS_MOSI48

The 02-gpio Sample Application

To see the state of the LED on the

DC9003

board, you need to close the LED EN jumper.

The 02-gpio sample application creates two tasks:

  • The gpioToggleTask() task configures a pin as output and toggles its state every second. On the 

    DC9003

     board, this corresponds to the blue LED.
  • The gpioNotifTask() task waits for notifications from a different pin configured as input. On the 

    DC9003

     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 byte 0x0a when the pin is tied high.
  • type "lowval 11" to send byte 0x0b 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 

On-Chip SDK repository

for documentation about this feature.