BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
14d55b21
Commit
14d55b21
authored
Oct 13, 2016
by
David Frey
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ashsyal-adc_gpio_tutorials'
parents
13758e3a
2b875853
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
459 additions
and
0 deletions
+459
-0
noiseData.adef
...torials/hardwareInterfaces/adc/NoiseSensor/noiseData.adef
+28
-0
Component.cdef
...erfaces/adc/NoiseSensor/noiseDataComponent/Component.cdef
+12
-0
noiseData.c
...Interfaces/adc/NoiseSensor/noiseDataComponent/noiseData.c
+58
-0
cf3GpioControl.adef
...ardwareInterfaces/gpio/Cf3GpioControl/cf3GpioControl.adef
+29
-0
Component.cdef
...pio/Cf3GpioControl/cf3GpioControlComponent/Component.cdef
+13
-0
cf3GpioControl.c
...o/Cf3GpioControl/cf3GpioControlComponent/cf3GpioControl.c
+83
-0
timerLed.adef
.../tutorials/hardwareInterfaces/gpio/TimerLed/timerLed.adef
+28
-0
Component.cdef
...Interfaces/gpio/TimerLed/timerLedComponent/Component.cdef
+12
-0
timerLed.c
...wareInterfaces/gpio/TimerLed/timerLedComponent/timerLed.c
+69
-0
touchData.adef
...orials/hardwareInterfaces/gpio/TouchSensor/touchData.adef
+29
-0
Component.cdef
...rfaces/gpio/TouchSensor/touchDataComponent/Component.cdef
+13
-0
touchData.c
...nterfaces/gpio/TouchSensor/touchDataComponent/touchData.c
+85
-0
No files found.
samples/tutorials/hardwareInterfaces/adc/NoiseSensor/noiseData.adef
0 → 100644
View file @
14d55b21
sandboxed: true
version: 1.0.0
maxFileSystemBytes: 512K
start: manual
executables:
{
noiseData = ( noiseDataComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( noiseData )
}
faultAction: restart
}
bindings:
{
noiseData.noiseDataComponent.le_adc -> modemService.le_adc
}
samples/tutorials/hardwareInterfaces/adc/NoiseSensor/noiseDataComponent/Component.cdef
0 → 100644
View file @
14d55b21
requires:
{
api:
{
${LEGATO_ROOT}/interfaces/modemServices/le_adc.api
}
}
sources:
{
noiseData.c
}
samples/tutorials/hardwareInterfaces/adc/NoiseSensor/noiseDataComponent/noiseData.c
0 → 100644
View file @
14d55b21
//--------------------------------------------------------------------------------------------------
/**
* This app reads the current adc reading every 1 seconds
*/
//--------------------------------------------------------------------------------------------------
#include "legato.h"
#include "interfaces.h"
//--------------------------------------------------------------------------------------------------
/**
* The time between publishing ADC location readings
*
* @note Please change this timeout value as needed.
*/
//--------------------------------------------------------------------------------------------------
#define ADC_SAMPLE_INTERVAL_IN_MILLISECONDS (1000)
//--------------------------------------------------------------------------------------------------
/**
* Timer handler will publish the current ADC reading.
*/
//--------------------------------------------------------------------------------------------------
static
void
adcTimer
(
le_timer_Ref_t
adcTimerRef
)
{
int32_t
value
;
const
le_result_t
result
=
le_adc_ReadValue
(
"EXT_ADC1"
,
&
value
);
if
(
result
==
LE_OK
)
{
LE_INFO
(
"EXT_ADC1 value is: %d"
,
value
);
}
else
{
LE_INFO
(
"Couldn't get ADC value"
);
}
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO
(
"---------------------- ADC Reading started"
);
le_timer_Ref_t
adcTimerRef
=
le_timer_Create
(
"ADC Timer"
);
le_timer_SetMsInterval
(
adcTimerRef
,
ADC_SAMPLE_INTERVAL_IN_MILLISECONDS
);
le_timer_SetRepeat
(
adcTimerRef
,
0
);
le_timer_SetHandler
(
adcTimerRef
,
adcTimer
);
le_timer_Start
(
adcTimerRef
);
}
samples/tutorials/hardwareInterfaces/gpio/Cf3GpioControl/cf3GpioControl.adef
0 → 100644
View file @
14d55b21
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_gpioPin25
cf3GpioControl.cf3GpioControlComponent.mangoh_ledGpio -> gpioExpanderService.mangoh_gpioExp1Pin5
}
samples/tutorials/hardwareInterfaces/gpio/Cf3GpioControl/cf3GpioControlComponent/Component.cdef
0 → 100644
View file @
14d55b21
requires:
{
api:
{
le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
cf3GpioControl.c
}
samples/tutorials/hardwareInterfaces/gpio/Cf3GpioControl/cf3GpioControlComponent/cf3GpioControl.c
0 → 100644
View file @
14d55b21
//--------------------------------------------------------------------------------------------------
/**
* 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.
*/
//--------------------------------------------------------------------------------------------------
#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
)
{
// set call back for change in state of GPIO
mangoh_ledGpio_SetEdgeSense
(
MANGOH_LEDGPIO_EDGE_BOTH
);
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
);
}
samples/tutorials/hardwareInterfaces/gpio/TimerLed/timerLed.adef
0 → 100644
View file @
14d55b21
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_gpioExp1Pin5
}
samples/tutorials/hardwareInterfaces/gpio/TimerLed/timerLedComponent/Component.cdef
0 → 100644
View file @
14d55b21
requires:
{
api:
{
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
timerLed.c
}
samples/tutorials/hardwareInterfaces/gpio/TimerLed/timerLedComponent/timerLed.c
0 → 100644
View file @
14d55b21
//--------------------------------------------------------------------------------------------------
/*
* This sample app is a blinking LED at 1 second interval
*/
//--------------------------------------------------------------------------------------------------
#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
);
}
samples/tutorials/hardwareInterfaces/gpio/TouchSensor/touchData.adef
0 → 100644
View file @
14d55b21
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_gpioExp1Pin7
touchData.touchDataComponent.mangoh_ledGpio -> gpioExpanderService.mangoh_gpioExp1Pin5
}
samples/tutorials/hardwareInterfaces/gpio/TouchSensor/touchDataComponent/Component.cdef
0 → 100644
View file @
14d55b21
requires:
{
api:
{
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api
}
}
sources:
{
touchData.c
}
samples/tutorials/hardwareInterfaces/gpio/TouchSensor/touchDataComponent/touchData.c
0 → 100644
View file @
14d55b21
//--------------------------------------------------------------------------------------------------
/**
* 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
*/
//--------------------------------------------------------------------------------------------------
#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
)
{
// set call back for change in state of GPIO
mangoh_ledGpio_SetEdgeSense
(
MANGOH_LEDGPIO_EDGE_BOTH
);
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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment