BigW Consortium Gitlab

Commit 09fdd608 by David Frey

Minor formatting cleanup of tutorials

parent 5685a272
...@@ -8,5 +8,5 @@ requires: ...@@ -8,5 +8,5 @@ requires:
sources: sources:
{ {
noiseData.c noiseData.c
} }
\ No newline at end of file
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* This app reads the current adc reading every 1 seconds * This app reads the current adc reading every 1 seconds
*/ */
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
#include "legato.h" #include "legato.h"
......
...@@ -2,12 +2,12 @@ requires: ...@@ -2,12 +2,12 @@ requires:
{ {
api: api:
{ {
le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
} }
} }
sources: sources:
{ {
cf3GpioControl.c cf3GpioControl.c
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* This sample app reads state of IoT1_GPIO1 (gpio25). * This sample app reads state of IoT1_GPIO1 (gpio25).
* If state change is detected, it makes corresponding change in state of LED D750. * 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 * Use this sample to understand how to configure a gpio as an input or output
...@@ -20,7 +20,6 @@ static void ConfigureLed ...@@ -20,7 +20,6 @@ static void ConfigureLed
) )
{ {
// Configure initial value as LED on // Configure initial value as LED on
LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK, LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK,
"Couldn't configure LED PLAY as a push pull output"); "Couldn't configure LED PLAY as a push pull output");
} }
...@@ -36,8 +35,7 @@ static void ConfigureSensorGpio ...@@ -36,8 +35,7 @@ static void ConfigureSensorGpio
) )
{ {
// Configure IoT1_GPIO1 as input and set its initial value as high // Configure IoT1_GPIO1 as input and set its initial value as high
LE_FATAL_IF(le_sensorGpio_SetInput(LE_SENSORGPIO_ACTIVE_HIGH) != LE_OK,
LE_FATAL_IF(le_sensorGpio_SetInput(LE_SENSORGPIO_ACTIVE_HIGH ) != LE_OK,
"Couldn't configure cf3 gpio as default input high"); "Couldn't configure cf3 gpio as default input high");
} }
...@@ -48,7 +46,8 @@ static void ConfigureSensorGpio ...@@ -48,7 +46,8 @@ static void ConfigureSensorGpio
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static void touch_ledGpio_ChangeHandler static void touch_ledGpio_ChangeHandler
( (
bool state, void *ctx bool state,
void *ctx
) )
{ {
// set call back for change in state of GPIO // set call back for change in state of GPIO
...@@ -69,8 +68,7 @@ static void touch_ledGpio_ChangeHandler ...@@ -69,8 +68,7 @@ static void touch_ledGpio_ChangeHandler
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
COMPONENT_INIT COMPONENT_INIT
{ {
LE_INFO("=============== CF3 gpio application has started");
LE_INFO("===============CF3 gpio application has started");
ConfigureLed(); ConfigureLed();
ConfigureSensorGpio(); ConfigureSensorGpio();
......
...@@ -28,7 +28,7 @@ static void ConfigureLed ...@@ -28,7 +28,7 @@ static void ConfigureLed
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* LED D750 changes state as defined by LED_SAMPLE_INTERVAL_IN_SECONDS * LED D750 changes state as defined by LED_SAMPLE_INTERVAL_IN_SECONDS
*/ */
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static void ledTimer static void ledTimer
......
...@@ -2,12 +2,12 @@ requires: ...@@ -2,12 +2,12 @@ requires:
{ {
api: api:
{ {
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api
mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api
} }
} }
sources: sources:
{ {
touchData.c touchData.c
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* This sample app reads state of IoT1_GPIO1 (gpio25) or Push Button SW200 * 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 * 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 * Use this sample to understand how to configure a gpio as an input or output
...@@ -22,7 +22,6 @@ static void ConfigureLed ...@@ -22,7 +22,6 @@ static void ConfigureLed
) )
{ {
// Configure initial value as LED on // Configure initial value as LED on
LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK, LE_FATAL_IF(mangoh_ledGpio_SetPushPullOutput(MANGOH_LEDGPIO_ACTIVE_HIGH, true) != LE_OK,
"Couldn't configure LED PLAY as a push pull output"); "Couldn't configure LED PLAY as a push pull output");
} }
...@@ -38,8 +37,7 @@ static void ConfigurePushButton ...@@ -38,8 +37,7 @@ static void ConfigurePushButton
) )
{ {
// Configure Push Button as input and set its initial value as high // Configure Push Button as input and set its initial value as high
LE_FATAL_IF(mangoh_pushButton_SetInput(MANGOH_PUSHBUTTON_ACTIVE_HIGH) != LE_OK,
LE_FATAL_IF(mangoh_pushButton_SetInput(MANGOH_PUSHBUTTON_ACTIVE_HIGH ) != LE_OK,
"Couldn't configure touch sensor as default input high"); "Couldn't configure touch sensor as default input high");
} }
...@@ -50,7 +48,8 @@ static void ConfigurePushButton ...@@ -50,7 +48,8 @@ static void ConfigurePushButton
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static void touch_ledGpio_ChangeHandler static void touch_ledGpio_ChangeHandler
( (
bool state, void *ctx bool state,
void *ctx
) )
{ {
// set call back for change in state of GPIO // set call back for change in state of GPIO
...@@ -71,8 +70,7 @@ static void touch_ledGpio_ChangeHandler ...@@ -71,8 +70,7 @@ static void touch_ledGpio_ChangeHandler
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
COMPONENT_INIT COMPONENT_INIT
{ {
LE_INFO("=============== touchsensor application has started");
LE_INFO("===============touchsensor application has started");
ConfigureLed(); ConfigureLed();
ConfigurePushButton(); ConfigurePushButton();
......
...@@ -23,8 +23,8 @@ processes: ...@@ -23,8 +23,8 @@ processes:
requires: requires:
{ {
device: device:
{ {
[rw] /dev/i2c-0 /dev/i2c-0 [rw] /dev/i2c-0 /dev/i2c-0
} }
} }
\ No newline at end of file
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* This app reads all the Register on BQ24196 or BQ24296 Battery Chargers * This app reads all the Register on BQ24196 or BQ24296 Battery Chargers
* It also writes output voltage for battery charger to 3.7V * It also writes output voltage for battery charger to 3.7V
*/ */
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
//* Static functions //* Static functions
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/** /**
* Get the file handle for the given I2C bus and configure it for access to the given I2C address. * Get the file handle for the given I2C bus and configure it for access to the given I2C address.
* *
...@@ -44,14 +45,14 @@ static int I2cAccessBusAddr ...@@ -44,14 +45,14 @@ static int I2cAccessBusAddr
if (errno == ENOENT) if (errno == ENOENT)
{ {
LE_ERROR( LE_ERROR(
"Could not open file /dev/i2c-%d or /dev/i2c/%d: %s\n", "Could not open file /dev/i2c-%d or /dev/i2c/%d: %s",
i2cBus, i2cBus,
i2cBus, i2cBus,
strerror(ENOENT)); strerror(ENOENT));
} }
else else
{ {
LE_ERROR("Could not open file %s': %s\n", filename, strerror(errno)); LE_ERROR("Could not open file %s': %s", filename, strerror(errno));
} }
return LE_FAULT; return LE_FAULT;
...@@ -59,7 +60,7 @@ static int I2cAccessBusAddr ...@@ -59,7 +60,7 @@ static int I2cAccessBusAddr
if (ioctl(fd, I2C_SLAVE_FORCE, i2cAddr) < 0) if (ioctl(fd, I2C_SLAVE_FORCE, i2cAddr) < 0)
{ {
LE_ERROR("Could not set address to 0x%02x: %s\n", i2cAddr, strerror(errno)); LE_ERROR("Could not set address to 0x%02x: %s", i2cAddr, strerror(errno));
return LE_FAULT; return LE_FAULT;
} }
...@@ -79,7 +80,7 @@ static le_result_t SmbusReadReg ...@@ -79,7 +80,7 @@ static le_result_t SmbusReadReg
( (
uint8_t i2cBus, ///< [IN] I2C bus to perform the read on uint8_t i2cBus, ///< [IN] I2C bus to perform the read on
uint8_t i2cAddr, ///< [IN] I2C address to read from uint8_t i2cAddr, ///< [IN] I2C address to read from
uint8_t reg, ///< [IN] Register within the I2C device to read uint8_t reg, ///< [IN] Register within the I2C device to read
uint8_t *data ///< [OUT] Value stored within the register. This value is only valid if the uint8_t *data ///< [OUT] Value stored within the register. This value is only valid if the
/// function returned LE_OK. /// function returned LE_OK.
) )
...@@ -87,7 +88,7 @@ static le_result_t SmbusReadReg ...@@ -87,7 +88,7 @@ static le_result_t SmbusReadReg
int i2cFd = I2cAccessBusAddr(i2cBus, i2cAddr); int i2cFd = I2cAccessBusAddr(i2cBus, i2cAddr);
if (i2cFd < 0) if (i2cFd < 0)
{ {
LE_ERROR("failed to open i2c bus %d for access to address %d\n", i2cBus, i2cAddr); LE_ERROR("failed to open i2c bus %d for access to address %d", i2cBus, i2cAddr);
return LE_FAULT; return LE_FAULT;
} }
...@@ -124,7 +125,7 @@ static le_result_t SmbusReadReg ...@@ -124,7 +125,7 @@ static le_result_t SmbusReadReg
static le_result_t SmbusWriteReg static le_result_t SmbusWriteReg
( (
uint8_t i2cBus, ////< I2C bus to perform the write on uint8_t i2cBus, ////< I2C bus to perform the write on
uint8_t i2cAddr, ////< I2C device address uint8_t i2cAddr, ////< I2C device address
uint8_t reg, ////< Register within the I2C device to write to uint8_t reg, ////< Register within the I2C device to write to
uint8_t data ////< Data to write to the given register uint8_t data ////< Data to write to the given register
) )
...@@ -133,7 +134,7 @@ int i2cFd = I2cAccessBusAddr(i2cBus, i2cAddr); ...@@ -133,7 +134,7 @@ int i2cFd = I2cAccessBusAddr(i2cBus, i2cAddr);
if (i2cFd == LE_FAULT) if (i2cFd == LE_FAULT)
{ {
LE_ERROR("failed to open i2c bus %d for access to address %d\n", i2cBus, i2cAddr); LE_ERROR("failed to open i2c bus %d for access to address %d", i2cBus, i2cAddr);
return LE_FAULT ; return LE_FAULT ;
} }
...@@ -170,7 +171,7 @@ static void EnableI2cBus ...@@ -170,7 +171,7 @@ static void EnableI2cBus
LE_DEBUG("Enabling TCA9546A I2C switch..."); LE_DEBUG("Enabling TCA9546A I2C switch...");
const int i2cBus = 0; const int i2cBus = 0;
const int i2cdev_fd = I2cAccessBusAddr(i2cBus, 0x71); const int i2cdev_fd = I2cAccessBusAddr(i2cBus, 0x71);
LE_FATAL_IF(i2cdev_fd == LE_FAULT, "failed to open i2cbus %d\n", i2cBus); LE_FATAL_IF(i2cdev_fd == LE_FAULT, "failed to open i2cbus %d", i2cBus);
const uint8_t enableAllPorts = 0xff; const uint8_t enableAllPorts = 0xff;
LE_FATAL_IF(i2c_smbus_write_byte(i2cdev_fd, enableAllPorts) == -1, "failed to write i2c data"); LE_FATAL_IF(i2c_smbus_write_byte(i2cdev_fd, enableAllPorts) == -1, "failed to write i2c data");
...@@ -191,37 +192,37 @@ static void ReadBatteryChargerRegister ...@@ -191,37 +192,37 @@ static void ReadBatteryChargerRegister
uint8_t RegisterReading; uint8_t RegisterReading;
SmbusReadReg(0, 0x6B, 0x00, &RegisterReading); SmbusReadReg(0, 0x6B, 0x00, &RegisterReading);
LE_DEBUG("Input Source Control value is %d\n",RegisterReading); LE_DEBUG("Input Source Control value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x01, &RegisterReading); SmbusReadReg(0, 0x6B, 0x01, &RegisterReading);
LE_DEBUG("Power-On Configuration Register value is %d\n",RegisterReading); LE_DEBUG("Power-On Configuration Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x02, &RegisterReading); SmbusReadReg(0, 0x6B, 0x02, &RegisterReading);
LE_DEBUG("Charge Current Control Register value is %d\n",RegisterReading); LE_DEBUG("Charge Current Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x03, &RegisterReading); SmbusReadReg(0, 0x6B, 0x03, &RegisterReading);
LE_DEBUG(" Pre-Charge/Termination Current Control Register value is %d\n",RegisterReading); LE_DEBUG(" Pre-Charge/Termination Current Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x04, &RegisterReading); SmbusReadReg(0, 0x6B, 0x04, &RegisterReading);
LE_DEBUG("Charge Voltage Control Register value is %d\n",RegisterReading); LE_DEBUG("Charge Voltage Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x05, &RegisterReading); SmbusReadReg(0, 0x6B, 0x05, &RegisterReading);
LE_DEBUG("Charge Termination/Timer Control Register value is %d\n",RegisterReading); LE_DEBUG("Charge Termination/Timer Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x06, &RegisterReading); SmbusReadReg(0, 0x6B, 0x06, &RegisterReading);
LE_DEBUG("Thermal Regulation Control Register value is %d\n",RegisterReading); LE_DEBUG("Thermal Regulation Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x07, &RegisterReading); SmbusReadReg(0, 0x6B, 0x07, &RegisterReading);
LE_DEBUG("Misc Operation Control Register value is %d\n",RegisterReading); LE_DEBUG("Misc Operation Control Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x08, &RegisterReading); SmbusReadReg(0, 0x6B, 0x08, &RegisterReading);
LE_DEBUG("System Status Register value is %d\n",RegisterReading); LE_DEBUG("System Status Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x09, &RegisterReading); SmbusReadReg(0, 0x6B, 0x09, &RegisterReading);
LE_DEBUG("Fault Register value is %d\n",RegisterReading); LE_DEBUG("Fault Register value is %d", RegisterReading);
SmbusReadReg(0, 0x6B, 0x0A, &RegisterReading); SmbusReadReg(0, 0x6B, 0x0A, &RegisterReading);
LE_DEBUG("Vender / Part / Revision Status Register value is %d\n",RegisterReading); LE_DEBUG("Vendor / Part / Revision Status Register value is %d", RegisterReading);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
...@@ -236,10 +237,10 @@ static void OutputBatteryChargerVoltage ...@@ -236,10 +237,10 @@ static void OutputBatteryChargerVoltage
) )
{ {
uint8_t OutputVoltage; uint8_t OutputVoltage;
SmbusWriteReg(0,0x6B,0x04,0xBA); SmbusWriteReg(0, 0x6B, 0x04, 0xBA);
SmbusReadReg(0, 0x6B, 0x04, &OutputVoltage); SmbusReadReg(0, 0x6B, 0x04, &OutputVoltage);
LE_DEBUG("Output voltage is set to %d\n",OutputVoltage); LE_DEBUG("Output voltage is set to %d", OutputVoltage);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
...@@ -250,8 +251,8 @@ static void OutputBatteryChargerVoltage ...@@ -250,8 +251,8 @@ static void OutputBatteryChargerVoltage
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
COMPONENT_INIT COMPONENT_INIT
{ {
LE_INFO("===============I2C Reading & Writing application has started"); LE_INFO("=============== I2C Reading & Writing application has started");
EnableI2cBus(); EnableI2cBus();
ReadBatteryChargerRegister(); ReadBatteryChargerRegister();
OutputBatteryChargerVoltage(); OutputBatteryChargerVoltage();
......
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