C examples: move mraa_init() calls out of C examples and into C drivers.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson 2016-09-28 17:33:57 -06:00
parent c3a5b8dd3c
commit e7c80217c2
68 changed files with 274 additions and 256 deletions

View File

@ -8,16 +8,9 @@
#include "a110x.h" #include "a110x.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
a110x_context dev = a110x_init(2); a110x_context dev = a110x_init(2);
bool abc = 0; bool abc = 0;
while(1){ while(1){

View File

@ -27,7 +27,6 @@
#include "bh1750.h" #include "bh1750.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "collision.h" #include "collision.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
collision_context dev = collision_init(2); collision_context dev = collision_init(2);
bool abc = 0; bool abc = 0;
while(1){ while(1){

View File

@ -27,7 +27,6 @@
#include "dfrec.h" #include "dfrec.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
printf("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "dfrorp.h" #include "dfrorp.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "dfrph.h" #include "dfrph.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -28,7 +28,6 @@
#include "ds18b20.h" #include "ds18b20.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -40,12 +39,6 @@ void sig_handler(int signo)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "emg.h" #include "emg.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "flex.h" #include "flex.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "gp2y0a.h" #include "gp2y0a.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
gp2y0a_context dev = gp2y0a_init(14, 5.0); gp2y0a_context dev = gp2y0a_init(14, 5.0);
float val; float val;
while(1){ while(1){

View File

@ -8,16 +8,9 @@
#include "grovemoisture.h" #include "grovemoisture.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
grovemoisture_context dev = grovemoisture_init(14); grovemoisture_context dev = grovemoisture_init(14);
int val; int val;
while(1){ while(1){

View File

@ -27,7 +27,6 @@
#include "gsr.h" #include "gsr.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "hka5.h" #include "hka5.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,8 +27,6 @@
#include "joystick12.h" #include "joystick12.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -40,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "ldt0028.h" #include "ldt0028.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "led.h" #include "led.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main(void) int main(void)
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
led_context dev = led_init(2); led_context dev = led_init(2);
while(1){ while(1){
if(led_on(dev) != UPM_SUCCESS){ if(led_on(dev) != UPM_SUCCESS){

View File

@ -27,7 +27,6 @@
#include "light.h" #include "light.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "loudness.h" #include "loudness.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
loudness_context dev = loudness_init(14); loudness_context dev = loudness_init(14);
int val; int val;
while(1){ while(1){

View File

@ -6,16 +6,9 @@
#include "m24lr64e.h" #include "m24lr64e.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
m24lr64e_context dev = m24lr64e_init(0, M24LR64E_USER_MODE); m24lr64e_context dev = m24lr64e_init(0, M24LR64E_USER_MODE);
int addr = M24LR64E_EEPROM_I2C_LENGTH-1; int addr = M24LR64E_EEPROM_I2C_LENGTH-1;
printf("address being accessed: %d\n", addr); printf("address being accessed: %d\n", addr);

View File

@ -27,7 +27,6 @@
#include "mma7361.h" #include "mma7361.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "moisture.h" #include "moisture.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
moisture_context dev = moisture_init(14); moisture_context dev = moisture_init(14);
int val; int val;
while(1){ while(1){

View File

@ -8,16 +8,9 @@
#include "mpr121.h" #include "mpr121.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
mpr121_context dev = mpr121_init(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR); mpr121_context dev = mpr121_init(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR);
if(mpr121_config_an3944(dev) != UPM_SUCCESS){ if(mpr121_config_an3944(dev) != UPM_SUCCESS){

View File

@ -8,16 +8,8 @@
#include "mq303a.h" #include "mq303a.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() { int main() {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
/* --------- MQ303A EXAMPLE -------- */ /* --------- MQ303A EXAMPLE -------- */
mq303a_context dev = mq303a_init(0, 15); mq303a_context dev = mq303a_init(0, 15);
printf("init done for mq303a\n"); printf("init done for mq303a\n");

View File

@ -27,7 +27,6 @@
#include "mqx.h" #include "mqx.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "nmea_gps.h" #include "nmea_gps.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -41,12 +40,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "nmea_gps.h" #include "nmea_gps.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -41,12 +40,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "o2.h" #include "o2.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "es08a.h" #include "es08a.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
es08a_context dev = es08a_init(3, ES08A_MIN_PULSE_WIDTH, ES08A_MAX_PULSE_WIDTH); es08a_context dev = es08a_init(3, ES08A_MIN_PULSE_WIDTH, ES08A_MAX_PULSE_WIDTH);
if(dev == NULL){ if(dev == NULL){
printf("unable to initialize the servo context\n"); printf("unable to initialize the servo context\n");

View File

@ -27,7 +27,6 @@
#include "sht1x.h" #include "sht1x.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "slide.h" #include "slide.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -8,16 +8,9 @@
#include "tsl2561.h" #include "tsl2561.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
tsl2561_context dev = tsl2561_init(0, TSL2561_Address, GAIN_0X, INTEGRATION_TIME1_101MS); tsl2561_context dev = tsl2561_init(0, TSL2561_Address, GAIN_0X, INTEGRATION_TIME1_101MS);
float abc = 0; float abc = 0;
if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){ if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){

View File

@ -8,16 +8,9 @@
#include "ttp223.h" #include "ttp223.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
ttp223_context dev = ttp223_init(2); ttp223_context dev = ttp223_init(2);
bool abc = 0; bool abc = 0;
while(1){ while(1){

View File

@ -27,7 +27,6 @@
#include "urm37.h" #include "urm37.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "urm37.h" #include "urm37.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -27,7 +27,6 @@
#include "vdiv.h" #include "vdiv.h"
#include "upm_utilities.h" #include "upm_utilities.h"
#include "mraa.h"
bool shouldRun = true; bool shouldRun = true;
@ -39,12 +38,6 @@ void sig_handler(int signo)
int main() int main()
{ {
if (mraa_init() != MRAA_SUCCESS)
{
perror("Failed to initialize mraa\n");
return -1;
}
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]

View File

@ -24,7 +24,15 @@
*/ */
#include "a110x.h" #include "a110x.h"
a110x_context a110x_init(uint8_t pin){ a110x_context a110x_init(uint8_t pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
a110x_context dev = a110x_context dev =
(a110x_context) malloc(sizeof(struct _a110x_context)); (a110x_context) malloc(sizeof(struct _a110x_context));

View File

@ -29,6 +29,14 @@
bh1750_context bh1750_init(int bus, uint8_t addr, BH1750_OPMODES_T mode) bh1750_context bh1750_init(int bus, uint8_t addr, BH1750_OPMODES_T mode)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
bh1750_context dev = bh1750_context dev =
(bh1750_context)malloc(sizeof(struct _bh1750_context)); (bh1750_context)malloc(sizeof(struct _bh1750_context));

View File

@ -24,7 +24,15 @@
*/ */
#include "collision.h" #include "collision.h"
collision_context collision_init(int pin){ collision_context collision_init(int pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
collision_context dev = collision_context dev =
(collision_context)malloc(sizeof(struct _collision_context)); (collision_context)malloc(sizeof(struct _collision_context));

View File

@ -60,6 +60,14 @@ static float average(const dfrec_context dev, int samples)
dfrec_context dfrec_init(unsigned int apin, unsigned int uart_ow, dfrec_context dfrec_init(unsigned int apin, unsigned int uart_ow,
unsigned int device_idx, float a_ref) unsigned int device_idx, float a_ref)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
dfrec_context dev = dfrec_context dev =
(dfrec_context)malloc(sizeof(struct _dfrec_context)); (dfrec_context)malloc(sizeof(struct _dfrec_context));

View File

@ -60,6 +60,14 @@ static float average(const dfrorp_context dev, int samples)
dfrorp_context dfrorp_init(unsigned int apin, float a_ref) dfrorp_context dfrorp_init(unsigned int apin, float a_ref)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
dfrorp_context dev = dfrorp_context dev =
(dfrorp_context)malloc(sizeof(struct _dfrorp_context)); (dfrorp_context)malloc(sizeof(struct _dfrorp_context));

View File

@ -29,6 +29,14 @@
dfrph_context dfrph_init(int16_t pin) dfrph_context dfrph_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
dfrph_context dev = dfrph_context dev =
(dfrph_context) malloc(sizeof(struct _dfrph_context)); (dfrph_context) malloc(sizeof(struct _dfrph_context));

View File

@ -49,6 +49,14 @@ static float readSingleTemp(const ds18b20_context dev, unsigned int index);
ds18b20_context ds18b20_init(unsigned int uart) ds18b20_context ds18b20_init(unsigned int uart)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
ds18b20_context dev = ds18b20_context dev =
(ds18b20_context)malloc(sizeof(struct _ds18b20_context)); (ds18b20_context)malloc(sizeof(struct _ds18b20_context));

View File

@ -29,6 +29,14 @@
emg_context emg_init(int16_t pin) emg_context emg_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
emg_context dev = (emg_context) malloc(sizeof(struct _emg_context)); emg_context dev = (emg_context) malloc(sizeof(struct _emg_context));
if (dev == NULL) if (dev == NULL)

View File

@ -29,6 +29,14 @@
flex_context flex_init(int16_t pin) flex_context flex_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
flex_context dev = (flex_context) malloc(sizeof(struct _flex_context)); flex_context dev = (flex_context) malloc(sizeof(struct _flex_context));
if (dev == NULL) if (dev == NULL)

View File

@ -29,6 +29,14 @@
mqx_context mqx_init(int16_t pin) mqx_context mqx_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
mqx_context dev = (mqx_context) malloc(sizeof(struct _mqx_context)); mqx_context dev = (mqx_context) malloc(sizeof(struct _mqx_context));
if (dev == NULL) if (dev == NULL)

View File

@ -25,6 +25,14 @@
#include "gp2y0a.h" #include "gp2y0a.h"
gp2y0a_context gp2y0a_init(uint8_t pin, float a_ref){ gp2y0a_context gp2y0a_init(uint8_t pin, float a_ref){
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
gp2y0a_context dev = (gp2y0a_context) malloc(sizeof(struct _gp2y0a_context)); gp2y0a_context dev = (gp2y0a_context) malloc(sizeof(struct _gp2y0a_context));
dev->pin = pin; dev->pin = pin;

View File

@ -29,6 +29,14 @@
gsr_context gsr_init(int16_t pin) gsr_context gsr_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
gsr_context dev = (gsr_context) malloc(sizeof(struct _gsr_context)); gsr_context dev = (gsr_context) malloc(sizeof(struct _gsr_context));
if (dev == NULL) if (dev == NULL)

View File

@ -50,6 +50,14 @@ static bool verify_cksum(uint8_t *pkt)
hka5_context hka5_init(unsigned int uart, int set_pin, int reset_pin) hka5_context hka5_init(unsigned int uart, int set_pin, int reset_pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
hka5_context dev = hka5_context dev =
(hka5_context)malloc(sizeof(struct _hka5_context)); (hka5_context)malloc(sizeof(struct _hka5_context));

View File

@ -29,6 +29,14 @@
joystick12_context joystick12_init(int16_t apin_x, int16_t apin_y) joystick12_context joystick12_init(int16_t apin_x, int16_t apin_y)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
joystick12_context dev = joystick12_context dev =
(joystick12_context) malloc(sizeof(struct _joystick12_context)); (joystick12_context) malloc(sizeof(struct _joystick12_context));

View File

@ -29,6 +29,14 @@
ldt0028_context ldt0028_init(int16_t pin) ldt0028_context ldt0028_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
ldt0028_context dev = (ldt0028_context) malloc(sizeof(struct _ldt0028_context)); ldt0028_context dev = (ldt0028_context) malloc(sizeof(struct _ldt0028_context));
if (dev == NULL) if (dev == NULL)

View File

@ -28,6 +28,14 @@
#include "upm_types.h" #include "upm_types.h"
led_context led_init(uint8_t pin){ led_context led_init(uint8_t pin){
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
led_context dev = led_context dev =
(led_context)malloc(sizeof(struct _led_context)); (led_context)malloc(sizeof(struct _led_context));

View File

@ -30,6 +30,14 @@
light_context light_init(int16_t pin) light_context light_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
light_context dev = (light_context) malloc(sizeof(struct _light_context)); light_context dev = (light_context) malloc(sizeof(struct _light_context));
if (dev == NULL) if (dev == NULL)

View File

@ -25,6 +25,14 @@
#include "loudness.h" #include "loudness.h"
loudness_context loudness_init(int pin) { loudness_context loudness_init(int pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
loudness_context dev = loudness_context dev =
(loudness_context) malloc(sizeof(struct _loudness_context)); (loudness_context) malloc(sizeof(struct _loudness_context));

View File

@ -48,6 +48,14 @@ upm_result_t m24lr64e_eeprom_write_bytes(m24lr64e_context dev,
uint8_t* data, int len); uint8_t* data, int len);
m24lr64e_context m24lr64e_init(int bus, m24lr64e_access_mode mode){ m24lr64e_context m24lr64e_init(int bus, m24lr64e_access_mode mode){
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
m24lr64e_context dev = m24lr64e_context dev =
(m24lr64e_context)malloc(sizeof(struct _m24lr64e_context)); (m24lr64e_context)malloc(sizeof(struct _m24lr64e_context));

View File

@ -53,6 +53,14 @@ mma7361_context mma7361_init(int x_pin, int y_pin, int z_pin,
return NULL; return NULL;
} }
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
mma7361_context dev = mma7361_context dev =
(mma7361_context)malloc(sizeof(struct _mma7361_context)); (mma7361_context)malloc(sizeof(struct _mma7361_context));

View File

@ -26,6 +26,14 @@
#include "moisture.h" #include "moisture.h"
moisture_context moisture_init(int pin) { moisture_context moisture_init(int pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
moisture_context dev = moisture_context dev =
(moisture_context) malloc(sizeof(struct _moisture_context)); (moisture_context) malloc(sizeof(struct _moisture_context));

View File

@ -25,7 +25,15 @@
#include "mpr121.h" #include "mpr121.h"
mpr121_context mpr121_init(int bus, uint8_t address){ mpr121_context mpr121_init(int bus, uint8_t address) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
mpr121_context dev = (mpr121_context)malloc(sizeof(struct _mpr121_context)); mpr121_context dev = (mpr121_context)malloc(sizeof(struct _mpr121_context));
if (!dev) if (!dev)

View File

@ -25,7 +25,15 @@
#include "mq303a.h" #include "mq303a.h"
mq303a_context mq303a_init(int pin, int heater_pin){ mq303a_context mq303a_init(int pin, int heater_pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
mq303a_context dev = mq303a_context dev =
(mq303a_context)malloc(sizeof(struct _mq303a_context)); (mq303a_context)malloc(sizeof(struct _mq303a_context));

View File

@ -71,6 +71,14 @@ static int readRegs(const nmea_gps_context dev, uint8_t reg,
nmea_gps_context nmea_gps_init(unsigned int uart, unsigned int baudrate, nmea_gps_context nmea_gps_init(unsigned int uart, unsigned int baudrate,
int enable_pin) int enable_pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
nmea_gps_context dev = nmea_gps_context dev =
(nmea_gps_context)malloc(sizeof(struct _nmea_gps_context)); (nmea_gps_context)malloc(sizeof(struct _nmea_gps_context));
@ -207,7 +215,8 @@ int nmea_gps_read(const nmea_gps_context dev, char *buffer, size_t len)
if (dev->i2c) if (dev->i2c)
{ {
int rv; int rv;
if ((rv = readRegs(dev, UBLOX6_I2C_BYTE_STREAM, buffer, len)) < 0) if ((rv = readRegs(dev, UBLOX6_I2C_BYTE_STREAM, (uint8_t *)buffer,
len)) < 0)
return rv; return rv;
// now we need to go through the bytes returned, and stop // now we need to go through the bytes returned, and stop

View File

@ -28,6 +28,14 @@
#include "o2.h" #include "o2.h"
o2_context o2_init(int16_t pin) o2_context o2_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
o2_context dev = (o2_context)malloc(sizeof(struct _o2_context)); o2_context dev = (o2_context)malloc(sizeof(struct _o2_context));
if(dev == NULL) return NULL; if(dev == NULL) return NULL;

View File

@ -25,7 +25,15 @@
#include "es08a.h" #include "es08a.h"
es08a_context es08a_init(int32_t pin, int32_t min_pulse_width, es08a_context es08a_init(int32_t pin, int32_t min_pulse_width,
int32_t max_pulse_width){ int32_t max_pulse_width) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
es08a_context dev = (es08a_context) malloc(sizeof(struct _es08a_context)); es08a_context dev = (es08a_context) malloc(sizeof(struct _es08a_context));
if(dev == NULL){ if(dev == NULL){
@ -104,4 +112,4 @@ int es08a_get_min_pulse_width (es08a_context dev){
int es08a_get_max_pulse_width (es08a_context dev){ int es08a_get_max_pulse_width (es08a_context dev){
return dev->max_pulse_width; return dev->max_pulse_width;
} }

View File

@ -25,7 +25,16 @@
#include "es9257.h" #include "es9257.h"
es9257_context es9257_init(int32_t pin, int32_t min_pulse_width, es9257_context es9257_init(int32_t pin, int32_t min_pulse_width,
int32_t max_pulse_width){ int32_t max_pulse_width) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
es9257_context dev = (es9257_context) malloc(sizeof(struct _es9257_context)); es9257_context dev = (es9257_context) malloc(sizeof(struct _es9257_context));
if(dev == NULL){ if(dev == NULL){

View File

@ -30,6 +30,14 @@
sht1x_context sht1x_init(unsigned int clk_pin, unsigned int data_pin) sht1x_context sht1x_init(unsigned int clk_pin, unsigned int data_pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
sht1x_context dev = sht1x_context dev =
(sht1x_context)malloc(sizeof(struct _sht1x_context)); (sht1x_context)malloc(sizeof(struct _sht1x_context));

View File

@ -29,6 +29,14 @@
slide_context slide_init(int16_t pin) slide_context slide_init(int16_t pin)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
slide_context dev = (slide_context) malloc(sizeof(struct _slide_context)); slide_context dev = (slide_context) malloc(sizeof(struct _slide_context));
if (dev == NULL) if (dev == NULL)

View File

@ -34,6 +34,14 @@ upm_result_t tsl2561_compute_lux(const tsl2561_context dev, int *int_data);
tsl2561_context tsl2561_init(int bus, uint8_t dev_address, uint8_t gain, tsl2561_context tsl2561_init(int bus, uint8_t dev_address, uint8_t gain,
uint8_t integration_time){ uint8_t integration_time){
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
tsl2561_context dev = tsl2561_context dev =
(tsl2561_context)malloc(sizeof(struct _tsl2561_context)); (tsl2561_context)malloc(sizeof(struct _tsl2561_context));

View File

@ -25,7 +25,15 @@
#include "ttp223.h" #include "ttp223.h"
ttp223_context ttp223_init(int pin){ ttp223_context ttp223_init(int pin) {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
ttp223_context dev = ttp223_context dev =
(ttp223_context) malloc(sizeof(struct _ttp223_context)); (ttp223_context) malloc(sizeof(struct _ttp223_context));

View File

@ -40,6 +40,13 @@ urm37_context urm37_init(uint8_t a_pin, uint8_t reset_pin,
uint8_t trigger_pin, float a_ref, uint8_t trigger_pin, float a_ref,
uint8_t uart_bus, bool analog_mode) uint8_t uart_bus, bool analog_mode)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
urm37_context dev = (urm37_context)malloc(sizeof(struct _urm37_context)); urm37_context dev = (urm37_context)malloc(sizeof(struct _urm37_context));

View File

@ -29,6 +29,14 @@
vdiv_context vdiv_init(int16_t pin, float voltage_ref) vdiv_context vdiv_init(int16_t pin, float voltage_ref)
{ {
// make sure MRAA is initialized
int mraa_rv;
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
{
printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
return NULL;
}
vdiv_context dev = (vdiv_context)malloc(sizeof(struct _vdiv_context)); vdiv_context dev = (vdiv_context)malloc(sizeof(struct _vdiv_context));
if (dev == NULL) return NULL; if (dev == NULL) return NULL;