How to use the Keypad?

hi everyone

im using a Airprime SL6087 Development Kit.
Im trying to write an application (in c) which shall do “some things” when the buttons on the bottom left corner are pressed.
Those buttons are labeled with “SW900”, “SW901”, … , “SW905” and are in a square which is labeld with “keypad”.
They are neither mentioned in the “AirPrime_SL6087_Development_Kit_User_Guide-Rev001.pdf” which i got together with it or in the adl manual. :frowning:

How do i subscripe to keypressed (or keyreleased) events(, which should be SOMEWHERE)?

Have a look at the Keyboard Library Sample included in the ADL Samples. To access this, create a new Library project, and select Keyboard from the samples. You can either use this library to subscribe to keyboard events, or look at the code to implement your own handlers.

uehm… library project? :open_mouth:

how do i create such a project?
im using “M2M Developer Suite 2.5” and i cant find it anywhere… neither on file->new -> projekt nor on file -> new -> other

the only example which sounded like something with keyboard is the dmtf keyboard example. It is using a keyhandler but the method doesnt get called when i press a button, so… whatever it is, thats not it :smiley:

on the sierra page one can download 2.35… i oehm… am i using the right software?! (currently i cant download it due to proxy problems…)

File -> New -> Open AT Project

In the Project Type section choose “Library”.

Latest version of Developer Studio is 2.1.0. Be careful not to look at the installer version, which is not the Developer Studio Version. You can see the Developer Studio Version in Help -> About Developer Studio.

a good place to hide an example :unamused:
thx so far

i cant get it running :blush: , so…
if i understand the at command manual (page 155) correctly i should get responses on the hyperterminal after ive sended the “at+cmer=,1” command (which gives me an “ok”), but i get no responses at all no matter how often or long i press the buttons…

if im just misunderstang it, this is my sourcecode
basicly ive taken the example and put a key_subscribe call into a main function (and every function creates an output when its called… but no function gets called after the key_subscribe at all

/* Keyboard Handler */
key_Handler_f key_Handler;

/* First Subscription flag */
bool    bOnce = TRUE;

/* Timer for key repetition */
adl_tmr_t * tRepeat;

/* Constants */
#define KEY_NONE    0xFF

/* Timer delays */
u32 key_RepeatTickTime;     // Timer before each repeat
u32 key_RepeatTickDelay;    // Delay before repeat

/* Prototypes */
bool key_UnsoHandler ( adl_atUnsolicited_t * Param );
void key_TimerHandler ( u8 Id, void * Context );

/* Keyboard Timer Handler */
void key_TimerHandler ( u8 Id, void * Context )
	adl_atSendResponse(ADL_AT_UNS, "key_TimerHandler\n");
	/* ReStart the Key timer, faster */
	tRepeat = adl_tmrSubscribe ( FALSE, key_RepeatTickTime, ADL_TMR_TYPE_TICK, key_TimerHandler );

	/* Call Unsolicited handler */
	key_UnsoHandler ( ( adl_atUnsolicited_t * ) NULL );

/* Keyboard unsolicited handler */
bool key_UnsoHandler ( adl_atUnsolicited_t * Param )
	adl_atSendResponse(ADL_AT_UNS, "key_UnsoHandler\n");
	u8      iKey = KEY_NONE,
			iPressed = 1;
	ascii   lBuffer[ 3 ];

	/* Last pressed key */
	static u8 iPressedKey = KEY_NONE;

	/* Get Key code */
	if ( Param )
		iKey     = wm_atoi ( wm_strGetParameterString ( lBuffer, Param->StrData, 1 ) );
		iPressed = wm_atoi ( wm_strGetParameterString ( lBuffer, Param->StrData, 2 ) );

	if ( iPressed )
		/* Key Pressed */
		if ( iKey != KEY_NONE )
			/* Save the pressed key */
			iPressedKey = iKey;

			/* Start the Key timer on the first time */
			if ( key_RepeatTickDelay )
				tRepeat = adl_tmrSubscribe ( FALSE, key_RepeatTickDelay, ADL_TMR_TYPE_TICK, key_TimerHandler );

		//TRACE (( key_TraceLevel, "Key pressed %d", iPressedKey ));

		/* Call Key handler */
		if ( key_Handler )
			key_Handler ( iPressedKey, iPressed );
		/* Stop the Key timer */
		adl_tmrUnSubscribe ( tRepeat, key_TimerHandler, ADL_TMR_TYPE_TICK );
		tRepeat = NULL;

		//TRACE (( key_TraceLevel, "Key released %d", iPressedKey ));

		/* Call Key handler */
		if ( key_Handler )
			key_Handler ( iPressedKey, iPressed );

		/* Reset the saved key */
		iPressedKey = KEY_NONE;

	/* Do not display keyboard events */
	return FALSE;

void KeyHandler(u8 Key, u8 Pressed){
	adl_atSendResponse(ADL_AT_UNS, "key_Handler\n");


/* Keyboard handler subscription */
void key_Subscribe ( key_Handler_f KeyHandler, u32 RepeatTickTime, u32 RepeatTickDelay )
	adl_atSendResponse(ADL_AT_UNS, "key_Subscribe\n");
	//TRACE (( key_TraceLevel, "Keyboard Handler Subscription (%d,%d)", RepeatTickTime, RepeatTickDelay ));

	/* Set Keyboard Handler */
	key_Handler = KeyHandler;

	/* Set Repeat Timers parameters */
	key_RepeatTickTime = RepeatTickTime ? RepeatTickTime : 1;
	key_RepeatTickDelay = RepeatTickDelay;

	if ( bOnce )
		/* Only first time */
		bOnce = FALSE;

		/* Send command to get keyboard events */
		adl_atCmdCreate ( "at+cmer=,1", FALSE, ( adl_atRspHandler_t ) NULL, NULL );

		/* Subscribe to Keyboard events */
		adl_atUnSoSubscribe ( "+CKEV: ", key_UnsoHandler );


/* Keyboard handler Unsubscription */
void key_Unsubscribe ( key_Handler_f KeyHandler )
	adl_atSendResponse(ADL_AT_UNS, "key_unSubscribe\n");
	//TRACE (( key_TraceLevel, "Keyboard Handler Unsubscription" ));

	if ( KeyHandler == key_Handler )
		/* Unsubscribe from keyboard handler */
		adl_atCmdCreate ( "at+cmer=,0", FALSE, ( adl_atRspHandler_t ) NULL, NULL );
		adl_atUnSoUnSubscribe ( "+CKEV: ", key_UnsoHandler );
		key_Handler = NULL;

		/* Unsubscribe from all timers */
		if ( tRepeat )
			adl_tmrUnSubscribe ( tRepeat, key_TimerHandler, ADL_TMR_TYPE_TICK );
			tRepeat = NULL;

		bOnce = TRUE;

void adl_main(adl_InitType_e adlInitType)
	adl_atSendResponse(ADL_AT_UNS, "Start of the Programm\n");
	key_Subscribe(KeyHandler, 1, 1);

and this is the entire output from when i start the programm via the “run as…” button

+WIND: 3
+WIND: 13
Start of the Programm

Ok, perform the following steps. This is what I did to get the keypad working on a WMP dev kit, it should be exactly the same on an SL dev kit:

  1. Click File -> New -> Open AT Project
  2. Name the project keyboard_sample_library, and select the Library type from the Project Type box
  3. Click Next, Next and select keyboard from the list of samples, Click Finish. A new library project should be opened in your workspace.
  4. Click File -> New -> Open AT Project
  5. Name the project and select Application from the Project Type box
  6. Click Next, Next, Next and check the box in Dependencies for keyboard_library_sample and click finish. A new application project should be created in your workspace.
  7. Add the following code to main.c in the application project:
#include "adl_global.h"
#include "keyboard.h"

void key_handler (u8 KeyIdx, u8 KeyPressed);

void main_task ( void )
    // TODO Insert your task initialization code here
    key_Subscribe(key_handler, 500, 1000);

void key_handler (u8 KeyIdx, u8 KeyPressed)
    TRACE((1, "[key_handler] A key was pressed: %d %d", KeyIdx, KeyPressed));
  1. Compile the code, and download to dev kit if no errors in complile
  2. Make sure you have level 1 traces enabled.
  3. Every time you press a button on the dev kit, you will see a trace telling you which key was pressed or released.


doesnt work either.
The subscribe method gets called but then nothing happens no matter how often or long i press any button

What version of the development kit do you have? Looking at the Universal Development Kit v3.0 User Guide, there are no keypad switches at all The following interfaces are listed for the SL6087:

External board to board connector and test point (TP) to access all signals for the adaptor board
Serial link RS232, UART1* with full signals
Ring Indicator
Serial link RS232, UART2* with four signals
Slave USB*, with SoftConnect™ signal. USB 2.0 Compliant (full speed)
SIM* (1.8/3V)
1 Audio connector (AUDIO2)
LEDs for several indications
Power supply connectors
RESET Pushbutton
ON/OFF switch
BOOT switch
Buzzer LED
Flash LED

Looking at the Product Technical specifications for the SL6087, there is NO keyboard interface at all. To access the swithes (assuming that are connected to GPIO), you would have to subscribe to the relevant GPIO using the GPIO services, and then receive events in the related callback.

good question…
it needed a bit of search (cause the model number of the develpment board is well hidden under the sl6087 modul…)
wm0502301-12-20 (only 1 google result… wow…)

i subscribed a function to the gpio events (adl_ioEventSubscribe) but it doesnt get called either T.T

the pdf found per google :smiley: says that the buttons connect rows with cols, which are (or seem) to be avaible on the j110 connector (which is to add an external board to the board, right? - so it doesnt help me)
the GPIOs are 4-12

ive run the gpio adl_ioGetCapabilitiesList example and the result is

Ressources : 26 GPIO, 0 GPI and 0 GPO 
List of GPIO :
GPIO 25 
GPIO 24 
GPIO 23 
GPIO 22 
GPIO 21 
GPIO 20 
GPIO 19 
GPIO 17 
GPIO 16 
GPIO 15 
GPIO 14 
GPIO 13 
GPIO 12 

i hope that the gpio numbers in internal use are the same as for the extern connector…
guess in addition to sl6087 not having a keyboard interface, that means i cant use the keypad which is on the board? :cry:

Looking under the GPIO section in the SL6087 PTS, GPIO 4 to GPIO 11 are multiplexed with UART1. This means that you will have to disable UART 1 and enable UART2 or USB for application download (See the AT command user guide for how to do this). Once UART1 is disabled, you should be able to subsribe to the required GPIO, and recieve switch events in the GPIO event handler (if the swithes are actually connected!).

deactivating the UART1 for… im starting to feel very uncomfortable with this developmentboard and its documentation…

since the at+whcnf command responses only with “error” if i try to change anything. So my next idea was to use the pins on the board…
there are plenty which are labeld with GPIOXX. At GPIO21 i even have an LED which shows the logical state of this GPIO :mrgreen:

When i connect it with the 2v8 pin (the docu says its I/O type is 2v8) the led burns. (so there should be a GPIO Event due to my understanding)

i subscribed a method via adl_ioEventSubscribe()

but it doesnt get called when the LED starts or stops to burn (which should mean that the status of GPIO21 Changes - which should be an event).
all i need is the “recognition” that a button has been pressed (which is now whired with the 2v8 and the GPIO21 pin). I need no periodic polling or whatsoever…

Have a look at the code below to make sure you are doing something similar (this is using a multitasking application, with a single task named gpioTask. Make sure this is indicated in your task table) :

#include "adl_global.h"
#include "generated.h"

/*  Local variables                                                                   
adl_ioDefs_t gpio_Input[1] =
s32 GPIO_event_handle = 0;
s32 Polling_handle;
/*  Local functions                                                                   
void GPIO_event_Handler(s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void *Param);

void gpioTask(void)
	// Subscribe to the GPIO Event System
	GPIO_event_handle = adl_ioEventSubscribe(GPIO_event_Handler);

	//subscribe to GPIO service with polling every 100ms for GPIO
	Polling_handle = adl_ioSubscribe(1, gpio_Input, ADL_TMR_TYPE_100MS, 1, GPIO_event_handle);

	// If both subscriptions were ok, return OK
	if ((GPIO_event_handle > 0) && (Polling_handle > 0))
		TRACE((1, "Subscribed to GPIO Events: OK"));
		TRACE((1, "Subscribed to GPIO Events: FAILED %d, %d",GPIO_event_handle, Polling_handle ));

void GPIO_event_Handler(s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void *Param)
	switch (Event)
			if (adl_ioReadSingle(Polling_handle, &gpio_Input[0]) == 1)