Gateway I/O Pins
Answer
5/9/17 1:54 PM

Hello everyone,

I am currently trying to use the Gateway's I/O Pins. However, I could not find a way to reach them. Related code snippet just like below. And my desire is just a basic control that if payload is 1, change the digital Pin's state off to on. (P.S : At the end of the code I tried to change pin state without any condition,  whether condition true or false, i tried to do Pin state on)

It may be wrong all of the code, thus please do not hesisate to correct me. I am open to all suggestions.

Thanks in advance,

static void clientRecv(MessageData* md)
{
	/* Initialize Variables */
	MQTTMessage* message = md->message;

	if((strncmp(md->topicName->lenstring.data, clientTopicSingleConfig_ptr, md->topicName->lenstring.len) == 0)) {
		/* Reconfigure the XDK */
		//clientReconfigure((char*)message->payload, (int) message->payloadlen);

		printf(md->message->payloadlen);
		if(message->payload == "0") {

			}

		else if (message->payload == "1") {

		}
	}
	else if((strncmp(md->topicName->lenstring.data, clientTopicGroupConfig_ptr, md->topicName->lenstring.len) == 0)) {
		/* Reconfigure the XDK */
		//clientReconfigure((char*)message->payload, (int) message->payloadlen );

	}

	printf("Subscribed Topic, %.*s, Message Received: %.*s\r\n", md->topicName->lenstring.len, md->topicName->lenstring.data,
			                                                   (int)message->payloadlen, (char*)message->payload);
			GPIO_handleInfo_t gpio;
			gpio.port = gpioPortB;
			gpio.bitIndex = 1;
			gpio.magicWord = GPIO_HANDLE_MAGIC_WORD;
			GPIO_init(&gpio, GPIO_DIRECTION_OUTPUT, GPIO_STATE_ON);
			GPIO_setPin(&gpio, GPIO_STATE_ON);
			
}
0 (0 Votes)
RE: Gateway I/O Pins
Answer
5/10/17 1:06 PM as a reply to Oguzhan Ciftci.

Hello Oguzhan,

I took a look at your code and have made some findings.
First of all, your code is not based on the highest available API level to implement the GPIO functionality and requires more configuration.

You can, of course, use it to implement the GPIO functionality, but I recommend to use the High Level API via the interface PTD_portDriver_ih.h.
Especially because then you have the advantage of suing the example code of code 5 on page 54 from the General Information guide. The example code shows how to toggle an external LED connected to a GPIO pin on the XDK extension bus.

I guess you can use it as starting point to implement your own toogle functionality.

If you want to continue with your code, then I recommend to remove the initialization of the GPIO pins. This initialization is done every time the XDK goes through the start up. Afterwards, I assume you should be able to observe a change of the current pin state.

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Votes)