BigW Consortium Gitlab

Commit 6acee2f2 by Mirac Chen

Provide GPIO tutorials for mangOH Red

parent 1b0e71d9
......@@ -25,3 +25,6 @@
[submodule "samples/Demos"]
path = samples/Demos
url = git://github.com/mangOH/Demos
[submodule "apps/GpioExpanderRed"]
path = apps/GpioExpanderRed
url = git://github.com/mangOH/GpioExpanderRed
Subproject commit 489a3ca992169d29fdbc9478c7349ba10a4b89da
sandboxed: true
version: 1.0.0
maxFileSystemBytes: 512K
start: manual
executables:
{
cf3GpioControl = ( cf3GpioControlComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( cf3GpioControl )
}
faultAction: restart
}
bindings:
{
cf3GpioControl.cf3GpioControlComponent.le_sensorGpio -> <root>.le_gpioPin7
cf3GpioControl.cf3GpioControlComponent.mangoh_ledGpio -> gpioExpanderService.mangoh_gpioExp1Pin4
}
\ No newline at end of file
requires:
{
api:
{
le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
cf3GpioControl.c
}
\ No newline at end of file
/**
* @file
*
* This sample app reads state of IoT1_GPIO1 (gpio25). If state change is detected, it makes
* corresponding change in state of LED D750. Use this sample to understand how to configure a gpio
* as an input or output and use call back function.
*
* <HR>
*
* Copyright (C) Sierra Wireless, Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
//--------------------------------------------------------------------------------------------------
/**
* Sets default configuration LED D750 as on
*/
//--------------------------------------------------------------------------------------------------
static void ConfigureLed
(
void
)
{
// Configure initial value as LED on
LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK,
"Couldn't configure LED PLAY as a push pull output");
}
//--------------------------------------------------------------------------------------------------
/**
* Performs initial configuration of the CF3 gpio (IoT1_GPIO1)
*/
//--------------------------------------------------------------------------------------------------
static void ConfigureSensorGpio
(
void
)
{
// Configure IoT1_GPIO1 as input and set its initial value as high
LE_FATAL_IF(le_sensorGpio_SetInput(LE_SENSORGPIO_ACTIVE_HIGH) != LE_OK,
"Couldn't configure cf3 gpio as default input high");
}
//--------------------------------------------------------------------------------------------------
/**
* LED D750 changes state when IoT1_GPIO1 changes state
*/
//--------------------------------------------------------------------------------------------------
static void touch_ledGpio_ChangeHandler
(
bool state,
void *ctx
)
{
if (state)
{
mangoh_ledGpio_Activate();
}
else
{
mangoh_ledGpio_Deactivate();
}
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO("=============== CF3 gpio application has started");
ConfigureLed();
ConfigureSensorGpio();
le_sensorGpio_AddChangeEventHandler(LE_SENSORGPIO_EDGE_BOTH,
touch_ledGpio_ChangeHandler,
NULL,
0);
}
sandboxed: true
version: 1.0.0
maxFileSystemBytes: 512K
start: manual
executables:
{
timerLed = ( timerLedComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( timerLed )
}
faultAction: restart
}
bindings:
{
timerLed.timerLedComponent.mangoh_ledGpio -> gpioExpanderService.mangoh_gpioExp1Pin4
}
\ No newline at end of file
requires:
{
api:
{
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
timerLed.c
}
\ No newline at end of file
/**
* @file
*
* This sample app is a blinking LED at 1 second interval
*
* <HR>
*
* Copyright (C) Sierra Wireless, Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
#define LED_SAMPLE_INTERVAL_IN_MILLISECONDS (1000)
static int8_t state = 0;
//--------------------------------------------------------------------------------------------------
/**
* Sets default configuration LED D750 as on
*/
//--------------------------------------------------------------------------------------------------
static void ConfigureLed
(
void
)
{
// Configure initial value as LED off
LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK,
"Couldn't configure LED PLAY as a push pull output");
}
//--------------------------------------------------------------------------------------------------
/**
* LED D750 changes state as defined by LED_SAMPLE_INTERVAL_IN_SECONDS
*/
//--------------------------------------------------------------------------------------------------
static void ledTimer
(
le_timer_Ref_t ledTimerRef
)
{
mangoh_ledGpio_SetEdgeSense(MANGOH_LEDGPIO_EDGE_BOTH);
if (state)
{
mangoh_ledGpio_Activate();
state = false;
}
else
{
mangoh_ledGpio_Deactivate();
state = true;
}
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO("===============blinking LED application has started");
ConfigureLed();
le_timer_Ref_t ledTimerRef = le_timer_Create("LED Timer");
le_timer_SetMsInterval(ledTimerRef, LED_SAMPLE_INTERVAL_IN_MILLISECONDS);
le_timer_SetRepeat(ledTimerRef, 0);
le_timer_SetHandler(ledTimerRef,ledTimer);
le_timer_Start(ledTimerRef);
}
\ No newline at end of file
sandboxed: true
version: 1.0.0
maxFileSystemBytes: 512K
start: manual
executables:
{
touchData = ( touchDataComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( touchData )
}
faultAction: restart
}
bindings:
{
touchData.touchDataComponent.mangoh_pushButton -> gpioExpanderService.mangoh_gpioExp1Pin3
touchData.touchDataComponent.mangoh_ledGpio -> gpioExpanderService.mangoh_gpioExp1Pin4
}
\ No newline at end of file
requires:
{
api:
{
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
touchData.c
}
\ No newline at end of file
/**
* @file
*
* This sample app reads state of IoT1_GPIO1 (gpio25) or Push Button SW200. If state change is
* detected, it makes corresponding change in state of LED D750. Use this sample to understand how
* to configure a gpio as an input or output and use call back function.
*
* <HR>
*
* Copyright (C) Sierra Wireless, Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
//--------------------------------------------------------------------------------------------------
/**
* Sets default configuration LED D750 as on
*/
//--------------------------------------------------------------------------------------------------
static void ConfigureLed
(
void
)
{
// Configure initial value as LED on
LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK,
"Couldn't configure LED PLAY as a push pull output");
}
//--------------------------------------------------------------------------------------------------
/**
* Performs initial configuration of the push button (SW200)
*/
//--------------------------------------------------------------------------------------------------
static void ConfigurePushButton
(
void
)
{
// Configure Push Button as input and set its initial value as high
LE_FATAL_IF(mangoh_pushButton_SetInput(MANGOH_PUSHBUTTON_ACTIVE_HIGH) != LE_OK,
"Couldn't configure touch sensor as default input high");
}
//--------------------------------------------------------------------------------------------------
/**
* LED D750 changes state when Push Button changes state
*/
//--------------------------------------------------------------------------------------------------
static void touch_ledGpio_ChangeHandler
(
bool state,
void *ctx
)
{
if (state)
{
mangoh_ledGpio_Activate();
}
else
{
mangoh_ledGpio_Deactivate();
}
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO("=============== touchsensor application has started");
ConfigureLed();
ConfigurePushButton();
mangoh_pushButton_AddChangeEventHandler(MANGOH_PUSHBUTTON_EDGE_BOTH,
touch_ledGpio_ChangeHandler,
NULL,
0);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment