Main Site Documentation

How do you switch digital outputs using RLP?


#1

Guys,
I’m trying to switch any of the digital outputs (D0 thru D6) on the bee board using RLP but can’t get it to work. I’ve tried:
GPIOA->ODR|=(1<<0);
GPIOB->ODR|=(1<<0);
Those didn’t work. I’ve tried replacing the 0 with 1 thru 12. That didn’t work.
I’ve tried:
RLP_Extension_T->GPIO.Writepin(0, false);
Had build errors with that one.
I’m using EM::Blocks and Simon’s common template
Can anyone please let me know what I’m doing wrong?
Thanks


#2

Your need to setup few registers first. I suggest is to use c# to make the pin high first and then use rlp to change its state.

There us an easier way. Use the rlp extensions.


#3

Hi Gus,
When you mean use RLP extensions, do you mean something like this?:
RLP_Extension_T->GPIO.Writepin(0, false);
When I try to build this, EM blocks gives me an error:
Expected identifier or ‘(’ before ‘->’ token
Can you please offer suggestions on the correct syntax?
Thanks


#4

Looks like it doesn’t like your RLP_Extension_T identifier.

Where and how is it defined?


#5

RLP.h file:
/*

  • Copyright © GHI Electronics, LLC. All rights reserved.
  • RLP support files.
  • This file should not be changed under any condition.
    */

#ifndef RLP_H
#define RLP_H

#ifdef EMX
#define RLP_ADDRESS 0xA0F00000
#define RLP_SIZE 0x000FFFFC
#elif defined G120
#define RLP_ADDRESS 0xA0F00000
#define RLP_SIZE 0x000FFFFC
#elif defined G400
#define RLP_ADDRESS 0xA0000000
#define RLP_SIZE 0x17FFFFC
#elif defined CERB_FAMILY
#define RLP_ADDRESS 0x2001C000
#define RLP_SIZE 0x0FFC
#else
#error You must define your board before including RLP.h.
#endif

#define RLP_TRUE 1
#define RLP_FALSE 0

#define RLP_GPIO_NONE 0xFFFFFFFF

#define RLP_GPIO_INT_NONE 0
#define RLP_GPIO_INT_EDGE_LOW 1
#define RLP_GPIO_INT_EDGE_HIGH 2
#define RLP_GPIO_INT_EDGE_BOTH 3
#define RLP_GPIO_INT_LEVEL_HIGH 4
#define RLP_GPIO_INT_LEVEL_LOW 5

#define RLP_GPIO_RESISTOR_DISABLED 0
#define RLP_GPIO_RESISTOR_PULLDOWN 1
#define RLP_GPIO_RESISTOR_PULLUP 2

#define RLP_TASK_DATA_SIZE 32

typedef void (RLP_CALLBACK_FPN)(void arg);
typedef void (RLP_GPIO_INTERRUPT_SERVICE_ROUTINE)(unsigned int pin, unsigned int pinState, void param);

typedef struct
{
unsigned int data[RLP_TASK_DATA_SIZE / 4];
} RLP_Task;

typedef struct
{
unsigned int GlitchFilterEnable;
unsigned int IntEdge;
unsigned int ResistorState;
} RLP_InterruptInputPinArgs;

typedef struct
{
unsigned int magic;
unsigned int firmwareVersion;
unsigned int magicSize;

struct
{
	unsigned int (*Install)(unsigned int irqIndex, RLP_CALLBACK_FPN isr, void* isrParam);
	unsigned int (*Uninstall)(unsigned int irqIndex);
	unsigned int (*Disable)(unsigned int irqIndex);
	unsigned int (*Enable)(unsigned int irqIndex);
	unsigned int (*IsEnabled)(unsigned int irqIndex);
	unsigned int (*IsPending)(unsigned int irqIndex);
	unsigned int (*GlobalInterruptDisable)();
	unsigned int (*GlobalInterruptEnable)();
	unsigned int (*IsGlobalInterruptEnabled)();

} Interrupt;

struct
{
	void (*EnableOutputMode)(unsigned int pin, unsigned int initialState);
	unsigned int (*EnableInputMode)(unsigned int pin, unsigned int resistorState);
	unsigned int (*EnableInterruptInputMode)(unsigned int pin, RLP_InterruptInputPinArgs* args, RLP_GPIO_INTERRUPT_SERVICE_ROUTINE isr, void* isrParam);
	unsigned int (*Readpin)(unsigned int pin);
	void (*Writepin)(unsigned int pin, unsigned int pinState);
	unsigned int (*Reservepin)(unsigned int pin, unsigned int reserve);
	unsigned int (*IsReserved)(unsigned int pin);
} GPIO;

void* (*malloc)(unsigned int length);
void (*free)(void* ptr);
void (*Delay)(unsigned int microSeconds);

void* (*malloc_CustomHeap)(unsigned int length);
void (*free_CustomHeap)(void* ptr);

struct
{
	void (*Initialize)(RLP_Task* task, RLP_CALLBACK_FPN taskCallback, void* arg, unsigned int isKernelMode);
	void (*Schedule)(RLP_Task* task);
	void (*ScheduleTimeOffset)(RLP_Task* task, unsigned int timeOffsetMicroseconds);
	void (*Abort)(RLP_Task* task);
	unsigned int (*IsScheduled)(RLP_Task* task);

} Task;

void (*PostManagedEvent)(unsigned int data);

} RLP_Extension_T;

#define RLP (*((RLP_Extension_T**)(RLP_ADDRESS + RLP_SIZE)))
#define RLP_EXT_MAGIC 0x73DE1BEA
#define RLP_MAGIC_SIZE sizeof(RLP_Extension_T)

#endif


#6

That is just the name of the structure. Use RLP instead that is the actual pointer for the structure.


RLP->GPIO.Writepin(0, false);


#7

Ok I’ve tried
RLP->GPIO.Writepin(0, false);
There’s a new error:
‘false’ undeclared (first use in this function)
Any ideas?
Thanks


#8

Try using 0 instead of ‘false’.


#9

Ok right after you said that I’ve noticed
(unsigned int pinState) in the Writepin definition.
I bet your right. I’ll give it a try when I get back to the computer. Why is it RLP-> and not RLP_Extension_T->?
Thanks


#10

In short, RLP_Extension_T is a name of the custom type. RLP is the name of a pointer to an instance of that type.

I highly recommend to go through a couple of tutorials on C/C++. You will save yourself a lot of time in a long run.


#11

Ok, thanks for your help


#12

Yep it’s working with:
RLP->GPIO.EnableOutputMode(4, 0); //A5 output on bee board
RLP->GPIO.Writepin(4, 0); // Write zero
RLP->GPIO.Writepin(4, 1); // Write one
Using the STM32F405 microcontroller, max toggle rates of the digital outputs went from about 45kHz to 1.7MHz. This will certainly help speed up communication with other ICs in my project. I don’t know how efficient the code is behind RLP->GPIO.Writepin so I’m going to try to write data to the GPIO port output data register (GPIOx_ODR) directly using RLP to see if I can achieve faster clock rates. Any thoughts on this?
Thanks


#13

You’ll probably get even better results.