2.6 Input/Output Configuration and Level Control of GPIO Pins

The RNBD451 module have General Purpose Input Output (GPIO) pins functionality assigned on certain pins on the 40-pin package. Out of all available pins, the GPIO pins that can be controlled using ASCII commands are defined as I/O level control by ASCII command. The RNBD451 module datasheet Table 3-1 captures the detailed pin description details for all available pins

For easy understanding, the GPIO pins that can be controlled using ASCII commands are captured in below table.

Note:In the RNBD451 Add on Board, the gpio pins are not brought out. This configurtation will be helpful for the module users.

Table: Pin Description
Pin NumberNameDefinition
14 PB8 I/O level control by RN command
17PB10I/O level control by RN command
18PB11I/O level control by RN command
20PA0I/O level control by RN command
21PA1I/O level control by RN command
22PB12I/O level control by RN command
23PB13I/O level control by RN command
32PA10I/O level control by RN command

The ASCII command provide the flexibility to configure these GPIO pins as either input and read its pins digital state or configure as output pins and set the desired output pin level to it. The functionality of configuring the pin as digital input and reading its value is made possible with Set Digital Input and Read Port (|I, <hex16>) command. By using the Set Digital Output Port (|O, <hex16>, <hex16>) command, the GPIO pin can be configured as Output pin and set its default level. For detailed description of these commands, refer to the RNBD451 Bluetooth Low Energy Module User’s Guide available in product page.

Individual bitmap values are assigned to each pin in the module firmware. Thus, the bitmap values are considered as an identification pointer for each pin. This method of assignation helps to configure multiple pins in singe command execution. Refer below table to understand the assigned bitmap values for each pin.

Table: Digital I/O Bitmap

BitmapRNBD451 Pins
0001PA0
0002PA1
0004Reserved
0008Reserved
0010PA10
0020Reserved
0040Reserved
0080PB8
0100PB10
0200PB11
0400PB12
0800PB13

1.1 Set Digital Input Command Implementation and Usage

Set Digital Input and Read Port (|I, <hex16>)

Format: |I, <hex16>

Command |I do the functionality of configure the pin as digital input and read the input level of the pin in single command execution. The command expects a hex16 value as its parameter which indicate the corresponding bitmap value of the RNBD451 pin. The Table: Digital I/O Bitmap provides details about the I/O pin bitmap format. The expected response for the command is also a bitmap. If the corresponding pin to read is high, then the bit in theresponse is set, otherwise, the bit is cleared

Example 1: Set Digital input pin PA0 and PA1 and read back

Example: |I,0003 // Read digital I/O PA0 and PA1.

// If return value is 0002,

// then PA0 is low and PA1 is high

Response: AOK // Success

ERR // Syntax error or invalid parameter

The general idea: If we want to configure multiple pins, then we need to add the bitmap values of the indented pins provide as input parameter to the command.

In the above example, the pins PA0 and PA1 are set as input and its input levels are read. For that, the corresponding bitmap values of PA0 and PA1 is added. That is 0001 + 0002 = 0003. The input should be in hex16 format for the command to process. Else the command respond Err.

If the response value received is 0002. That shows that the PA0 is low and PA1 is high.

The corresponding binary equivalent value will give more idea about the pins state.

Binary equivalent of 2 is 0010

0(Reserved) 0(Reserved) 1(PA1) 0(PA0)

Example 2: Set Digital input pin PA10 and PB8 and read back

Example: |I,0090 // Read digital I/O PA10 and PB8.

// If return value is 0090,

Response: AOK // Success

ERR // Syntax error or invalid parameter

In the above example, the pins PA10 and PB8 are set as input and its input levels are read. For that, the corresponding bitmap values of PA0 and PA1 is added. That is 0010 + 0080 = 0090

If the response value received is 0090. That shows that the PA10 is High and PB8 is high.

Binary equivalent of 90 is 1001 0000

1(PB8) 0(Reserved) 0(Reserved) 1(PA10) 0(Reserved) 0(Reserved) 0(PA1) 0(PA0)